public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [POSIX][PATCH] Remove POSIX non-compliant API pthread_getattr_np
@ 2010-11-02  7:44 Bian Naimeng
  2010-11-02  8:00 ` Bian Naimeng
  0 siblings, 1 reply; 3+ messages in thread
From: Bian Naimeng @ 2010-11-02  7:44 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list

The pthread_getattr_np is not a POSIX compliant API, it's unnecessary to test it.

Signed-off-by: Bian Naimeng <biannm@cn.fujitsu.com>

---
 .../interfaces/pthread_attr_setstacksize/2-1.c     |   17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
index 668fd96..c91c946 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
@@ -14,7 +14,6 @@
  * 4.  In the created thread, read stacksize
  */
 
-/* For pthread_getattr_np(3) -- not a POSIX compliant API */
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
@@ -35,21 +34,13 @@
 size_t stack_size;
 void *stack_addr;
 
-void *thread_func()
+void *thread_func(void *arg)
 {
-	pthread_attr_t attr;
+	pthread_attr_t *pattr = (pthread_attr_t *)arg;
 	size_t ssize;
 	int rc;
 
-	if ((rc = pthread_getattr_np(pthread_self(), &attr)) != 0) {
-		printf(ERROR_PREFIX "pthread_getattr_np: %s\n", strerror(rc));
-		exit(PTS_FAIL);
-	}
-	if ((rc = pthread_attr_init(&attr)) != 0) {
-		printf(ERROR_PREFIX "pthread_attr_init: %s\n", strerror(rc));
-		exit(PTS_FAIL);
-	}
-	if ((rc = pthread_attr_getstacksize(&attr, &ssize)) != 0) {
+	if ((rc = pthread_attr_getstacksize(pattr, &ssize)) != 0) {
 		printf(ERROR_PREFIX "pthread_attr_getstacksize: %s\n",
 			strerror(rc));
 		exit(PTS_FAIL);
@@ -106,7 +97,7 @@ int main()
                 exit(PTS_UNRESOLVED);
         }
 
-	rc = pthread_create(&new_th, &attr, thread_func, NULL);
+	rc = pthread_create(&new_th, &attr, thread_func, &attr);
 	if (rc != 0) {
                 printf(ERROR_PREFIX "pthread_create: %s\n", strerror(rc));
                 exit(PTS_FAIL);
-- 
1.7.0.4


-- 
Regards
Bian Naimeng


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [POSIX][PATCH] Remove POSIX non-compliant API pthread_getattr_np
  2010-11-02  7:44 [LTP] [POSIX][PATCH] Remove POSIX non-compliant API pthread_getattr_np Bian Naimeng
@ 2010-11-02  8:00 ` Bian Naimeng
  2010-11-08 21:25   ` Garrett Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Bian Naimeng @ 2010-11-02  8:00 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list

Sorry to make a noise, please ignore this patch.
However, maybe PTS_UNRESOLVED is better if "ssize != stacksize" at the child thread.

Bian Naimeng wrote:
> The pthread_getattr_np is not a POSIX compliant API, it's unnecessary to test it.
> 
> Signed-off-by: Bian Naimeng <biannm@cn.fujitsu.com>
> 
> ---
>  .../interfaces/pthread_attr_setstacksize/2-1.c     |   17 ++++-------------
>  1 files changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
> index 668fd96..c91c946 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
> @@ -14,7 +14,6 @@
>   * 4.  In the created thread, read stacksize
>   */
>  
> -/* For pthread_getattr_np(3) -- not a POSIX compliant API */
>  #ifndef _GNU_SOURCE
>  #define _GNU_SOURCE
>  #endif
> @@ -35,21 +34,13 @@
>  size_t stack_size;
>  void *stack_addr;
>  
> -void *thread_func()
> +void *thread_func(void *arg)
>  {
> -	pthread_attr_t attr;
> +	pthread_attr_t *pattr = (pthread_attr_t *)arg;
>  	size_t ssize;
>  	int rc;
>  
> -	if ((rc = pthread_getattr_np(pthread_self(), &attr)) != 0) {
> -		printf(ERROR_PREFIX "pthread_getattr_np: %s\n", strerror(rc));
> -		exit(PTS_FAIL);
> -	}
> -	if ((rc = pthread_attr_init(&attr)) != 0) {
> -		printf(ERROR_PREFIX "pthread_attr_init: %s\n", strerror(rc));
> -		exit(PTS_FAIL);
> -	}
> -	if ((rc = pthread_attr_getstacksize(&attr, &ssize)) != 0) {
> +	if ((rc = pthread_attr_getstacksize(pattr, &ssize)) != 0) {
>  		printf(ERROR_PREFIX "pthread_attr_getstacksize: %s\n",
>  			strerror(rc));
>  		exit(PTS_FAIL);
> @@ -106,7 +97,7 @@ int main()
>                  exit(PTS_UNRESOLVED);
>          }
>  
> -	rc = pthread_create(&new_th, &attr, thread_func, NULL);
> +	rc = pthread_create(&new_th, &attr, thread_func, &attr);
>  	if (rc != 0) {
>                  printf(ERROR_PREFIX "pthread_create: %s\n", strerror(rc));
>                  exit(PTS_FAIL);

-- 
Regards
Bian Naimeng


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [POSIX][PATCH] Remove POSIX non-compliant API pthread_getattr_np
  2010-11-02  8:00 ` Bian Naimeng
@ 2010-11-08 21:25   ` Garrett Cooper
  0 siblings, 0 replies; 3+ messages in thread
From: Garrett Cooper @ 2010-11-08 21:25 UTC (permalink / raw)
  To: Bian Naimeng; +Cc: ltp-list

On Tue, Nov 2, 2010 at 1:00 AM, Bian Naimeng <biannm@cn.fujitsu.com> wrote:
> Sorry to make a noise, please ignore this patch.
> However, maybe PTS_UNRESOLVED is better if "ssize != stacksize" at the child thread.
>
> Bian Naimeng wrote:
>> The pthread_getattr_np is not a POSIX compliant API, it's unnecessary to test it.
>>
>> Signed-off-by: Bian Naimeng <biannm@cn.fujitsu.com>
>>
>> ---
>>  .../interfaces/pthread_attr_setstacksize/2-1.c     |   17 ++++-------------
>>  1 files changed, 4 insertions(+), 13 deletions(-)
>>
>> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
>> index 668fd96..c91c946 100644
>> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
>> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/2-1.c
>> @@ -14,7 +14,6 @@
>>   * 4.  In the created thread, read stacksize
>>   */
>>
>> -/* For pthread_getattr_np(3) -- not a POSIX compliant API */
>>  #ifndef _GNU_SOURCE
>>  #define _GNU_SOURCE
>>  #endif
>> @@ -35,21 +34,13 @@
>>  size_t stack_size;
>>  void *stack_addr;
>>
>> -void *thread_func()
>> +void *thread_func(void *arg)
>>  {
>> -     pthread_attr_t attr;
>> +     pthread_attr_t *pattr = (pthread_attr_t *)arg;
>>       size_t ssize;
>>       int rc;
>>
>> -     if ((rc = pthread_getattr_np(pthread_self(), &attr)) != 0) {
>> -             printf(ERROR_PREFIX "pthread_getattr_np: %s\n", strerror(rc));
>> -             exit(PTS_FAIL);
>> -     }
>> -     if ((rc = pthread_attr_init(&attr)) != 0) {
>> -             printf(ERROR_PREFIX "pthread_attr_init: %s\n", strerror(rc));
>> -             exit(PTS_FAIL);
>> -     }
>> -     if ((rc = pthread_attr_getstacksize(&attr, &ssize)) != 0) {
>> +     if ((rc = pthread_attr_getstacksize(pattr, &ssize)) != 0) {
>>               printf(ERROR_PREFIX "pthread_attr_getstacksize: %s\n",
>>                       strerror(rc));
>>               exit(PTS_FAIL);
>> @@ -106,7 +97,7 @@ int main()
>>                  exit(PTS_UNRESOLVED);
>>          }
>>
>> -     rc = pthread_create(&new_th, &attr, thread_func, NULL);
>> +     rc = pthread_create(&new_th, &attr, thread_func, &attr);
>>       if (rc != 0) {
>>                  printf(ERROR_PREFIX "pthread_create: %s\n", strerror(rc));
>>                  exit(PTS_FAIL);

Possibly, but the only problem with that is that there really needs to
be a means to sample the current thread stack size. That's what's
missing that needs to go into the POSIX spec.
-Garrett

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-08 21:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-02  7:44 [LTP] [POSIX][PATCH] Remove POSIX non-compliant API pthread_getattr_np Bian Naimeng
2010-11-02  8:00 ` Bian Naimeng
2010-11-08 21:25   ` Garrett Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox