src/solaris/transport/socket/socket_md.c

Print this page




  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include <stdlib.h>
  27 #include <sys/types.h>
  28 #include <sys/socket.h>
  29 #include <netinet/in.h>
  30 #include <arpa/inet.h>
  31 #include <unistd.h>
  32 #include <fcntl.h>
  33 #include <errno.h>
  34 #include <string.h>
  35 #include <sys/time.h>
  36 #ifdef __solaris__
  37 #include <thread.h>
  38 #endif
  39 #if defined(__linux__) || defined(_ALLBSD_SOURCE)
  40 #include <pthread.h>
  41 #include <sys/poll.h>
  42 #endif
  43 
  44 #include "socket_md.h"
  45 #include "sysSocket.h"
  46 
  47 int
  48 dbgsysListen(int fd, int backlog) {
  49     return listen(fd, backlog);
  50 }
  51 
  52 int
  53 dbgsysConnect(int fd, struct sockaddr *name, int namelen) {
  54     int rv = connect(fd, name, namelen);
  55     if (rv < 0 && (errno == EINPROGRESS || errno == EINTR)) {
  56         return DBG_EINPROGRESS;
  57     } else {
  58         return rv;
  59     }


 289     return (int)tk;
 290 }
 291 
 292 void
 293 dbgsysTlsFree(int index) {
 294    /* no-op */
 295 }
 296 
 297 void
 298 dbgsysTlsPut(int index, void *value) {
 299     thr_setspecific((thread_key_t)index, value) ;
 300 }
 301 
 302 void *
 303 dbgsysTlsGet(int index) {
 304     void* r = NULL;
 305     thr_getspecific((thread_key_t)index, &r);
 306     return r;
 307 }
 308 
 309 #endif
 310 
 311 #if defined(__linux__) || defined(_ALLBSD_SOURCE)
 312 int
 313 dbgsysTlsAlloc() {
 314     pthread_key_t key;
 315     if (pthread_key_create(&key, NULL)) {
 316         perror("pthread_key_create");
 317         exit(-1);
 318     }
 319     return (int)key;
 320 }
 321 
 322 void
 323 dbgsysTlsFree(int index) {
 324     pthread_key_delete((pthread_key_t)index);
 325 }
 326 
 327 void
 328 dbgsysTlsPut(int index, void *value) {
 329     pthread_setspecific((pthread_key_t)index, value) ;
 330 }
 331 


  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #include <stdlib.h>
  27 #include <sys/types.h>
  28 #include <sys/socket.h>
  29 #include <netinet/in.h>
  30 #include <arpa/inet.h>
  31 #include <unistd.h>
  32 #include <fcntl.h>
  33 #include <errno.h>
  34 #include <string.h>
  35 #include <sys/time.h>
  36 #ifdef __solaris__
  37 #include <thread.h>
  38 #else

  39 #include <pthread.h>
  40 #include <sys/poll.h>
  41 #endif
  42 
  43 #include "socket_md.h"
  44 #include "sysSocket.h"
  45 
  46 int
  47 dbgsysListen(int fd, int backlog) {
  48     return listen(fd, backlog);
  49 }
  50 
  51 int
  52 dbgsysConnect(int fd, struct sockaddr *name, int namelen) {
  53     int rv = connect(fd, name, namelen);
  54     if (rv < 0 && (errno == EINPROGRESS || errno == EINTR)) {
  55         return DBG_EINPROGRESS;
  56     } else {
  57         return rv;
  58     }


 288     return (int)tk;
 289 }
 290 
 291 void
 292 dbgsysTlsFree(int index) {
 293    /* no-op */
 294 }
 295 
 296 void
 297 dbgsysTlsPut(int index, void *value) {
 298     thr_setspecific((thread_key_t)index, value) ;
 299 }
 300 
 301 void *
 302 dbgsysTlsGet(int index) {
 303     void* r = NULL;
 304     thr_getspecific((thread_key_t)index, &r);
 305     return r;
 306 }
 307 
 308 #else


 309 int
 310 dbgsysTlsAlloc() {
 311     pthread_key_t key;
 312     if (pthread_key_create(&key, NULL)) {
 313         perror("pthread_key_create");
 314         exit(-1);
 315     }
 316     return (int)key;
 317 }
 318 
 319 void
 320 dbgsysTlsFree(int index) {
 321     pthread_key_delete((pthread_key_t)index);
 322 }
 323 
 324 void
 325 dbgsysTlsPut(int index, void *value) {
 326     pthread_setspecific((pthread_key_t)index, value) ;
 327 }
 328