Re: OpenSSL question for id_function()
In article [EMAIL PROTECTED], Craig Rodrigues [EMAIL PROTECTED] wrote: pthread_self() returns something of type pthread_t. This code works under Linux, because pthread_t is mapped to an integer value. However, on FreeBSD, pthread_t is a pointer to struct pthread, so this code does not compile: FreeBSD violates POSIX in this respect. The 1003.1 standard (section 2.5) requires pthread_t to be an arithmetic type. We are non-compliant in the same way for almost all of the primary thread-related types: pthread_attr_t pthread_mutex_t pthread_mutexattr_t pthread_cond_t pthread_condattr_t pthread_once_t We got it right for pthread_key_t, though. :-) John -- John Polstra John D. Polstra Co., Inc.Seattle, Washington USA Disappointment is a good sign of basic intelligence. -- Chögyam Trungpa To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: OpenSSL question for id_function()
On Thu, Feb 27, 2003 at 08:40:22AM -0800, John Polstra wrote: FreeBSD violates POSIX in this respect. Doh! I just looked at: http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libpthread/include/pthread.h and it looks like OpenBSD does the same thing. Just wondering, is the FreeBSD KSE project implementing a POSIX compliant pthread_t? thread-related types: pthread_attr_t pthread_mutex_t pthread_mutexattr_t pthread_cond_t pthread_condattr_t pthread_once_t We got it right for pthread_key_t, though. :-) Cool. Sometimes standards are a pain in the neck, but my main interest in FreeBSD's POSIX compliance for threads is to be more and more of a drop-in replacement for Linux. :) So is OpenSSL stuff which requires id_function() broken on FreeBSD then? The C++-style work-around for my code is to do: return reinterpret_castunsigned long(pthread_self()); which is similar to Lev Walkin's suggestion for a C style cast. This gets things to compile, but seems like trying to fit a square peg in a round hole Thanks. -- Craig Rodrigues http://home.attbi.com/~rodrigc [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: OpenSSL question for id_function()
John Polstra [EMAIL PROTECTED] writes: In article [EMAIL PROTECTED], Craig Rodrigues [EMAIL PROTECTED] wrote: pthread_self() returns something of type pthread_t. This code works under Linux, because pthread_t is mapped to an integer value. However, on FreeBSD, pthread_t is a pointer to struct pthread, so this code does not compile: FreeBSD violates POSIX in this respect. The 1003.1 standard (section 2.5) requires pthread_t to be an arithmetic type. We are non-compliant in the same way for almost all of the primary thread-related types: pthread_attr_t pthread_mutex_t pthread_mutexattr_t pthread_cond_t pthread_condattr_t pthread_once_t We got it right for pthread_key_t, though. :-) It looks like this requirement was removed in POSIX.1-2001. A problem with our implementation is that struct pthread* is in the implementation namespace, so we can't define these types in sys/types.h as required. Best regards, Mike Barcroft To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: OpenSSL question for id_function()
In article [EMAIL PROTECTED], Mike Barcroft [EMAIL PROTECTED] wrote: John Polstra [EMAIL PROTECTED] writes: FreeBSD violates POSIX in this respect. The 1003.1 standard (section 2.5) requires pthread_t to be an arithmetic type. It looks like this requirement was removed in POSIX.1-2001. Interesting. I don't have that standard and wasn't aware of the change. Are you sure the requirement was removed? It was hidden away in an obscure place in the 1996 edition of the standard. There's a table of Primitive System Data Types containing the usual suspects (dev_t, gid_t, uid_t, ...) and including the thread types I mentioned. Then there's a sentence in the nearby text that says, All of the types listed in Table 2-1 shall be arithmetic types ... John -- John Polstra John D. Polstra Co., Inc.Seattle, Washington USA Disappointment is a good sign of basic intelligence. -- Chögyam Trungpa To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: OpenSSL question for id_function()
On Thu, 27 Feb 2003 08:40:22 -0800 (PST), John Polstra [EMAIL PROTECTED] said: FreeBSD violates POSIX in this respect. The 1003.1 standard (section 2.5) requires pthread_t to be an arithmetic type. We are non-compliant in the same way for almost all of the primary thread-related types: Not so (with respect to those other types). XBD page 367: # All of the types shall be defined as arithmetic types of an # appropriate length, with the following exceptions: # # key_t # pthread_attr_t # pthread_barrier_t # pthread_barrierattr_t # pthread_cond_t # pthread_condattr_t # pthread_key_t # pthread_mutex_t # pthread_mutexattr_t # pthread_once_t # pthread_rwlock_t # pthread_rwlockattr_t # pthread_spinlock_t # trace_attr_t # trace_event_id_t # trace_event_set_t # trace_id_t SSWG-RT got a bit carried away with pthread_t, I think, because they define a comparison operation (pthread_equal()) even though such an operation is never necessary on arithmetic types (the `=' operator can be used for that purpose). We could define pthread_t as __intptr_t without making significant changes to the implementation. -GAWollman To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: OpenSSL question for id_function()
On Thu, 27 Feb 2003 09:06:41 -0800 (PST), John Polstra [EMAIL PROTECTED] said: Interesting. I don't have that standard and wasn't aware of the change. You do. It's available for free on the Web from opengroup.org. Free registration is required. Mike may still have some copies of the official guidebook to the standard, which includes the final text PDFs, which were donated by The Open Group. -GAWollman To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: OpenSSL question for id_function()
John Polstra [EMAIL PROTECTED] writes: In article [EMAIL PROTECTED], Mike Barcroft [EMAIL PROTECTED] wrote: John Polstra [EMAIL PROTECTED] writes: FreeBSD violates POSIX in this respect. The 1003.1 standard (section 2.5) requires pthread_t to be an arithmetic type. It looks like this requirement was removed in POSIX.1-2001. Interesting. I don't have that standard and wasn't aware of the change. Are you sure the requirement was removed? It was hidden away in an obscure place in the 1996 edition of the standard. There's a table of Primitive System Data Types containing the usual suspects (dev_t, gid_t, uid_t, ...) and including the thread types I mentioned. Then there's a sentence in the nearby text that says, All of the types listed in Table 2-1 shall be arithmetic types ... Here's the text: : 12974 All of the types shall be defined as arithmetic types of an appropriate length, with the following : 12975 exceptions: : 12976 XSI key_t : 12977 THR pthread_attr_t : 12978 BAR pthread_barrier_t : 12979 pthread_barrierattr_t : 12980 THR pthread_cond_t : 12981 pthread_condattr_t : 12982 pthread_key_t : 12983 pthread_mutex_t : 12984 pthread_mutexattr_t : 12985 pthread_once_t : 12986 pthread_rwlock_t : 12987 pthread_rwlockattr_t : 12988 SPI pthread_spinlock_t : 12989 TRC trace_attr_t : 12990 trace_event_id_t : 12991 TRC TEF trace_event_set_t : 12992 TRC trace_id_t So it looks like pthread_t must be an arithmetic type, but not the others. My mistake. It goes on to say: : 13010 There are no defined comparison or assignment operators for the following types: : 13011 THR pthread_attr_t : 13012 BAR pthread_barrier_t : 13013 pthread_barrierattr_t : 13014 THR pthread_cond_t : 13015 pthread_condattr_t : 13016 pthread_mutex_t : 13017 pthread_mutexattr_t : 13018 pthread_rwlock_t : 13019 pthread_rwlockattr_t : 13020 SPI pthread_spinlock_t : 13021 TRC trace_attr_t Again pthread_t isn't listed. Best regards, Mike Barcroft To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: OpenSSL question for id_function()
In article [EMAIL PROTECTED], Mike Barcroft [EMAIL PROTECTED] wrote: So it looks like pthread_t must be an arithmetic type, but not the others. Great. Thanks for checking! John -- John Polstra John D. Polstra Co., Inc.Seattle, Washington USA Disappointment is a good sign of basic intelligence. -- Chögyam Trungpa To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: OpenSSL question for id_function()
In article [EMAIL PROTECTED], Garrett Wollman [EMAIL PROTECTED] wrote: We could define pthread_t as __intptr_t without making significant changes to the implementation. Agreed. I think it would be nicer if it were a small integer like a file descriptor -- i.e., an index into a table containing the actual structures. I suspect that was the intent of the standard writers. But faking it into an __intptr_t would satisfy the text of the standard. John -- John Polstra John D. Polstra Co., Inc.Seattle, Washington USA Disappointment is a good sign of basic intelligence. -- Chögyam Trungpa To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: OpenSSL question for id_function()
On 27-Feb-2003 Craig Rodrigues wrote: On Thu, Feb 27, 2003 at 08:40:22AM -0800, John Polstra wrote: FreeBSD violates POSIX in this respect. Doh! I just looked at: http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libpthread/include/pthread.h and it looks like OpenBSD does the same thing. Just wondering, is the FreeBSD KSE project implementing a POSIX compliant pthread_t? thread-related types: pthread_attr_t pthread_mutex_t pthread_mutexattr_t pthread_cond_t pthread_condattr_t pthread_once_t We got it right for pthread_key_t, though. :-) Cool. Sometimes standards are a pain in the neck, but my main interest in FreeBSD's POSIX compliance for threads is to be more and more of a drop-in replacement for Linux. :) So is OpenSSL stuff which requires id_function() broken on FreeBSD then? The C++-style work-around for my code is to do: return reinterpret_castunsigned long(pthread_self()); Use uintptr_t or intptr_t rather than unsigned long. -- John Baldwin [EMAIL PROTECTED]http://www.FreeBSD.org/~jhb/ Power Users Use the Power to Serve! - http://www.FreeBSD.org/ To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: OpenSSL question for id_function()
Maybe it is possbile to create wrappers for these types in your portable program Is pthread_t a simple handle for the memory location of the pthread_t strucutre? On Thu, 2003-02-27 at 11:40, John Polstra wrote: In article [EMAIL PROTECTED], Craig Rodrigues [EMAIL PROTECTED] wrote: pthread_self() returns something of type pthread_t. This code works under Linux, because pthread_t is mapped to an integer value. However, on FreeBSD, pthread_t is a pointer to struct pthread, so this code does not compile: FreeBSD violates POSIX in this respect. The 1003.1 standard (section 2.5) requires pthread_t to be an arithmetic type. We are non-compliant in the same way for almost all of the primary thread-related types: pthread_attr_t pthread_mutex_t pthread_mutexattr_t pthread_cond_t pthread_condattr_t pthread_once_t We got it right for pthread_key_t, though. :-) John -- John Polstra John D. Polstra Co., Inc.Seattle, Washington USA Disappointment is a good sign of basic intelligence. -- Chögyam Trungpa To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message -- The Law of Leaky Abstractions There is a time where abstractions lead to the inablity to fix problems that leak through the abstraction. http://www.joelonsoftware.com/articles/LeakyAbstractions.html To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: OpenSSL question for id_function()
Craig Rodrigues wrote: return static_castunsigned long(pthread_self()); pthread_self() returns something of type pthread_t. This code works under Linux, because pthread_t is mapped to an integer value. However, on FreeBSD, pthread_t is a pointer to struct pthread, so this code does not compile: OpenSSLPluginI.cpp: In function `long unsigned int IceSSL::idFunction()': OpenSSLPluginI.cpp:153: invalid static_cast from type `pthread*' to type `long unsigned int' Is there a way to implement the id_function() for OpenSSL so that it works portably across FreeBSD and Linux? return (unsigned long)(void *)(pthread_self()); -- Lev Walkin [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message