/* LSB wrapper implementation This unit conrains wrappers for non-lsb functions that are used throughout the OpenJDK project. It dynamically loads them and implements functions to check their availibility in runtime as well as wrapper implementations with the same name as the original. */ #include "lsb_config.h" #include "lsb_helpers.h" #ifndef __LSB_PROVIDES_libthread_db #include LSB_LIB_LOAD(thread_db,"libthread_db.so"); LSB_CHECKER(thread_db,td_init); LSB_CHECKER(thread_db,td_ta_new); LSB_CHECKER(thread_db,td_thr_get_info); LSB_CHECKER(thread_db,td_ta_thr_iter); LSB_CHECKER(thread_db,td_ta_delete); /* As this function is used as checker for correct libthread_db loader in OpenJDK code, let it return error gracefully if td_init wasn't actually loaded. We also rely on this function as on the first function from libthread_db called in openjdk code. So, we do some dlopen magic here for it to be loaded correctly. */ td_err_e td_init (void) { /* libthread_db contains several undefined symbols that should be found in the library it's linked agains in compile time. As we don't link it in compile time due to its possible inavailability, we have to use dlopen magic and re-open libsaproc.so to allow consequent dlsyms to find undefined symbols dynamically. */ dlopen("libsaproc.so",RTLD_NOW|RTLD_GLOBAL); if (!td_init_available()){ fprintf(stderr,"Due to absence of libthread_db, the functionality is not supported on your system.\n"); return TD_ERR; } LSB_WRAPPER_CALL(td_init); } td_err_e td_ta_new (struct ps_prochandle *__ps, td_thragent_t **__ta) { LSB_WRAPPER_CALL(td_ta_new,__ps,__ta); } td_err_e td_ta_delete (td_thragent_t *__ta) { LSB_WRAPPER_CALL(td_ta_delete,__ta); } td_err_e td_ta_thr_iter (const td_thragent_t *__ta, td_thr_iter_f *__callback, void *__cbdata_p, td_thr_state_e __state, int __ti_pri, sigset_t *__ti_sigmask_p, unsigned int __ti_user_flags) { LSB_WRAPPER_CALL(td_ta_thr_iter,__ta,__callback,__cbdata_p,__state,__ti_pri,__ti_sigmask_p,__ti_user_flags); } td_err_e td_thr_get_info (const td_thrhandle_t *__th, td_thrinfo_t *__infop) { LSB_WRAPPER_CALL(td_thr_get_info,__th,__infop); } #endif // __LSB_PROVIDES_libthread_db #ifndef __LSB_PROVIDES_ptrace #include LSB_CHECKER(DEFAULT,ptrace); long int ptrace(enum __ptrace_request request, pid_t pid, void *addr, void *data) { LSB_WRAPPER_CALL(ptrace,request,pid,addr,data); } #endif // LSB_PROVIDES_ptrace #ifndef __LSB_PROVIDES_dlvsym #include // wrappers are assigned to DEFAULT library -- see lsb_wrappers.h LSB_CHECKER(DEFAULT,dlvsym); void *dlvsym(void *handle, char const *symbol, char const *version) { LSB_WRAPPER_CALL(dlvsym,handle,symbol,version); } #endif // __LSB_PROVIDES_dlvsym #ifndef __LSB_PROVIDES_pthread_getattr_np #include #include // wrappers are assigned to DEFAULT library -- see lsb_wrappers.h LSB_CHECKER(DEFAULT,pthread_getattr_np); int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) { LSB_WRAPPER_CALL(pthread_getattr_np,__th,__attr); } #endif #ifndef __LSB_PROVIDES_sysinfo #include #include LSB_CHECKER(DEFAULT,sysinfo); int sysinfo (struct sysinfo *__info) { LSB_WRAPPER_CALL(sysinfo,__info); } #endif #ifndef __LSB_PROVIDES_mincore #include LSB_CHECKER(DEFAULT,mincore); int mincore (void *__start, size_t __len, unsigned char *__vec) { LSB_WRAPPER_CALL(mincore,__start,__len,__vec); } #endif #ifndef __LSB_PROVIDES_getmntent_r #include LSB_CHECKER(DEFAULT,getmntent_r); struct mntent *getmntent_r (FILE *__restrict __stream, struct mntent *__restrict __result, char *__restrict __buffer, int __bufsize) { LSB_WRAPPER_CALL(getmntent_r,__stream,__result,__buffer,__bufsize); } #endif #ifndef __LSB_PROVIDES_setmntent #include LSB_CHECKER(DEFAULT,setmntent); FILE *setmntent (__const char *__file, __const char *__mode) { LSB_WRAPPER_CALL(setmntent,__file,__mode); } #endif #ifndef __LSB_PROVIDES_endmntent #include LSB_CHECKER(DEFAULT,endmntent); int endmntent (FILE *__stream) { LSB_WRAPPER_CALL(endmntent,__stream); } #endif #ifndef __LSB_PROVIDES_snd_rawmidi_info #include LSB_CHECKER(DEFAULT,snd_rawmidi_info); int snd_rawmidi_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info) { LSB_WRAPPER_CALL(snd_rawmidi_info,rmidi,info); } #endif #ifndef __LSB_PROVIDES_snd_rawmidi_info_get_card #include LSB_CHECKER(DEFAULT,snd_rawmidi_info_get_card); int snd_rawmidi_info_get_card(const snd_rawmidi_info_t *obj) { LSB_WRAPPER_CALL(snd_rawmidi_info_get_card,obj); } #endif