Ticket #71265: patch-add-pthread_chdir_np.diff

File patch-add-pthread_chdir_np.diff, 4.6 KB (added by RJVB (René Bertin), 4 days ago)

draft implementation

  • include/MacportsLegacySupport.h

    diff --git a/include/MacportsLegacySupport.h b/include/MacportsLegacySupport.h
    index 9ac8b2e..fee2b42 100644
    a b  
    350350                                                            || __MPLS_TARGET_OSVER == 1090 \
    351351                                                            || __MPLS_TARGET_OSVER <  1060)
    352352
     353/* pthread_?chdir_np */
     354#define __MPLS_SDK_SUPPORT_PTHREAD_CHDIR_NP__   (__MPLS_SDK_MAJOR < 101200)
     355#define __MPLS_LIB_SUPPORT_PTHREAD_CHDIR_NP__   (__MPLS_TARGET_OSVER < 101200)
     356
    353357#endif /* _MACPORTS_LEGACYSUPPORTDEFS_H_ */
  • src/add_symbols.c

    diff --git a/src/add_symbols.c b/src/add_symbols.c
    index 2243728..62af0fc 100644
    a b extern const char pthread_get_stacksize_np_tmp5 __asm("$ld$add$os10.5$_pthread_g 
    8888extern const char pthread_get_stacksize_np_tmp9 __asm("$ld$add$os10.9$_pthread_get_stacksize_np"); __attribute__((visibility("default"))) const char pthread_get_stacksize_np_tmp9 = 0;
    8989extern const char pthread_get_stacksize_np_tmp10 __asm("$ld$add$os10.10$_pthread_get_stacksize_np"); __attribute__((visibility("default"))) const char pthread_get_stacksize_np_tmp10 = 0;
    9090#endif
     91
     92#if !(__MPLS_LIB_SUPPORT_PTHREAD_CHDIR_NP__)
     93extern const char pthread_chdir_np_tmp4 __asm("$ld$add$os10.4$_pthread_chdir_np"); __attribute__((visibility("default"))) const char pthread_chdir_np_tmp4 = 0;
     94extern const char pthread_fchdir_np_tmp4 __asm("$ld$add$os10.4$_pthread_fchdir_np"); __attribute__((visibility("default"))) const char pthread_fchdir_np_tmp4 = 0;
     95extern const char pthread_chdir_np_tmp5 __asm("$ld$add$os10.5$_pthread_chdir_np"); __attribute__((visibility("default"))) const char pthread_chdir_np_tmp5 = 0;
     96extern const char pthread_fchdir_np_tmp5 __asm("$ld$add$os10.5$_pthread_fchdir_np"); __attribute__((visibility("default"))) const char pthread_fchdir_np_tmp5 = 0;
     97extern const char pthread_chdir_np_tmp6 __asm("$ld$add$os10.6$_pthread_chdir_np"); __attribute__((visibility("default"))) const char pthread_chdir_np_tmp7 = 0;
     98extern const char pthread_fchdir_np_tmp6 __asm("$ld$add$os10.6$_pthread_fchdir_np"); __attribute__((visibility("default"))) const char pthread_fchdir_np_tmp6 = 0;
     99extern const char pthread_chdir_np_tmp7 __asm("$ld$add$os10.7$_pthread_chdir_np"); __attribute__((visibility("default"))) const char pthread_chdir_np_tmp7 = 0;
     100extern const char pthread_fchdir_np_tmp7 __asm("$ld$add$os10.7$_pthread_fchdir_np"); __attribute__((visibility("default"))) const char pthread_fchdir_np_tmp7 = 0;
     101extern const char pthread_chdir_np_tmp8 __asm("$ld$add$os10.8$_pthread_chdir_np"); __attribute__((visibility("default"))) const char pthread_chdir_np_tmp8 = 0;
     102extern const char pthread_fchdir_np_tmp8 __asm("$ld$add$os10.8$_pthread_fchdir_np"); __attribute__((visibility("default"))) const char pthread_fchdir_np_tmp8 = 0;
     103extern const char pthread_chdir_np_tmp9 __asm("$ld$add$os10.9$_pthread_chdir_np"); __attribute__((visibility("default"))) const char pthread_chdir_np_tmp9 = 0;
     104extern const char pthread_fchdir_np_tmp9 __asm("$ld$add$os10.9$_pthread_fchdir_np"); __attribute__((visibility("default"))) const char pthread_fchdir_np_tmp9 = 0;
     105extern const char pthread_chdir_np_tmp10 __asm("$ld$add$os10.10$_pthread_chdir_np"); __attribute__((visibility("default"))) const char pthread_chdir_np_tmp10 = 0;
     106extern const char pthread_fchdir_np_tmp10 __asm("$ld$add$os10.10$_pthread_fchdir_np"); __attribute__((visibility("default"))) const char pthread_fchdir_np_tmp10 = 0;
     107extern const char pthread_chdir_np_tmp11 __asm("$ld$add$os10.11$_pthread_chdir_np"); __attribute__((visibility("default"))) const char pthread_chdir_np_tmp11 = 0;
     108extern const char pthread_fchdir_np_tmp11 __asm("$ld$add$os10.11$_pthread_fchdir_np"); __attribute__((visibility("default"))) const char pthread_fchdir_np_tmp11 = 0;
     109#endif
     110
  • new file src/pthread_chdir_np.c

    diff --git a/src/pthread_chdir_np.c b/src/pthread_chdir_np.c
    new file mode 100644
    index 0000000..07f750e
    - +  
     1/* MP support header */
     2#include "MacportsLegacySupport.h"
     3
     4#if __MPLS_LIB_SUPPORT_PTHREAD_CHDIR_NP__
     5
     6#include <sys/syscall.h>
     7#include <unistd.h>
     8
     9int pthread_chdir_np(const char *path) {
     10#if __MPLS_TARGET_OSVER >= 1050
     11  return syscall(SYS___pthread_chdir, path);
     12#else
     13  // the pthread_?chdir syscalls are available since 10.5
     14  return -1;
     15#endif
     16}
     17
     18int pthread_fchdir_np(int fd) {
     19#if __MPLS_TARGET_OSVER >= 1050
     20  return syscall(SYS___pthread_fchdir, fd);
     21#else
     22  // the pthread_?chdir syscalls are available since 10.5
     23  return -1;
     24#endif
     25}
     26
     27#endif /* __MPLS_LIB_SUPPORT_PTHREAD_CHDIR_NP__ */