$FreeBSD$ --- coregrind/m_syswrap/syswrap-freebsd.c.orig +++ coregrind/m_syswrap/syswrap-freebsd.c @@ -57,6 +57,7 @@ #include "priv_syswrap-generic.h" #include "priv_syswrap-freebsd.h" +#include // Run a thread from beginning to end and return the thread's // scheduler-return-code. @@ -1389,18 +1390,19 @@ PRINT( "sys_inotify_rm_watch ( %ld, %lx )", ARG1,ARG2); PRE_REG_READ2(long, "inotify_rm_watch", int, fd, int, wd); } +#endif /* --------------------------------------------------------------------- mq_* wrappers ------------------------------------------------------------------ */ -PRE(sys_mq_open) +PRE(sys_kmq_open) { - PRINT("sys_mq_open( %#lx(%s), %ld, %lld, %#lx )", + PRINT("sys_kmq_open( %#lx(%s), %ld, %lld, %#lx )", ARG1,(char *)ARG1,ARG2,(ULong)ARG3,ARG4); PRE_REG_READ4(long, "mq_open", const char *, name, int, oflag, vki_mode_t, mode, - struct mq_attr *, attr); + struct vki_mq_attr *, attr); PRE_MEM_RASCIIZ( "mq_open(name)", ARG1 ); if ((ARG2 & VKI_O_CREAT) != 0 && ARG4 != 0) { const struct vki_mq_attr *attr = (struct vki_mq_attr *)ARG4; @@ -1410,7 +1412,7 @@ (Addr)&attr->mq_msgsize, sizeof(attr->mq_msgsize) ); } } -POST(sys_mq_open) +POST(sys_kmq_open) { vg_assert(SUCCESS); if (!ML_(fd_allowed)(RES, "mq_open", tid, True)) { @@ -1422,17 +1424,17 @@ } } -PRE(sys_mq_unlink) +PRE(sys_kmq_unlink) { - PRINT("sys_mq_unlink ( %#lx(%s) )", ARG1,(char *)ARG1); + PRINT("sys_kmq_unlink ( %#lx(%s) )", ARG1,(char *)ARG1); PRE_REG_READ1(long, "mq_unlink", const char *, name); PRE_MEM_RASCIIZ( "mq_unlink(name)", ARG1 ); } -PRE(sys_mq_timedsend) +PRE(sys_kmq_timedsend) { *flags |= SfMayBlock; - PRINT("sys_mq_timedsend ( %ld, %#lx, %llu, %ld, %#lx )", + PRINT("sys_kmq_timedsend ( %ld, %#lx, %llu, %ld, %#lx )", ARG1,ARG2,(ULong)ARG3,ARG4,ARG5); PRE_REG_READ5(long, "mq_timedsend", vki_mqd_t, mqdes, const char *, msg_ptr, vki_size_t, msg_len, @@ -1447,10 +1449,10 @@ } } -PRE(sys_mq_timedreceive) +PRE(sys_kmq_timedreceive) { *flags |= SfMayBlock; - PRINT("sys_mq_timedreceive( %ld, %#lx, %llu, %#lx, %#lx )", + PRINT("sys_kmq_timedreceive( %ld, %#lx, %llu, %#lx, %#lx )", ARG1,ARG2,(ULong)ARG3,ARG4,ARG5); PRE_REG_READ5(ssize_t, "mq_timedreceive", vki_mqd_t, mqdes, char *, msg_ptr, vki_size_t, msg_len, @@ -1468,16 +1470,16 @@ ARG5, sizeof(struct vki_timespec) ); } } -POST(sys_mq_timedreceive) +POST(sys_kmq_timedreceive) { POST_MEM_WRITE( ARG2, ARG3 ); if (ARG4 != 0) POST_MEM_WRITE( ARG4, sizeof(unsigned int) ); } -PRE(sys_mq_notify) +PRE(sys_kmq_notify) { - PRINT("sys_mq_notify( %ld, %#lx )", ARG1,ARG2 ); + PRINT("sys_kmq_notify( %ld, %#lx )", ARG1,ARG2 ); PRE_REG_READ2(long, "mq_notify", vki_mqd_t, mqdes, const struct sigevent *, notification); if (!ML_(fd_allowed)(ARG1, "mq_notify", tid, False)) @@ -1487,33 +1489,31 @@ ARG2, sizeof(struct vki_sigevent) ); } -PRE(sys_mq_getsetattr) +PRE(sys_kmq_setattr) { - PRINT("sys_mq_getsetattr( %ld, %#lx, %#lx )", ARG1,ARG2,ARG3 ); - PRE_REG_READ3(long, "mq_getsetattr", + PRINT("sys_kmq_setattr( %ld, %#lx, %#lx )", ARG1,ARG2,ARG3 ); + PRE_REG_READ3(long, "mq_setattr", vki_mqd_t, mqdes, const struct mq_attr *, mqstat, struct mq_attr *, omqstat); - if (!ML_(fd_allowed)(ARG1, "mq_getsetattr", tid, False)) { + if (!ML_(fd_allowed)(ARG1, "mq_setattr", tid, False)) { SET_STATUS_Failure( VKI_EBADF ); } else { if (ARG2 != 0) { const struct vki_mq_attr *attr = (struct vki_mq_attr *)ARG2; - PRE_MEM_READ( "mq_getsetattr(mqstat->mq_flags)", + PRE_MEM_READ( "mq_setattr(mqstat->mq_flags)", (Addr)&attr->mq_flags, sizeof(attr->mq_flags) ); } if (ARG3 != 0) - PRE_MEM_WRITE( "mq_getsetattr(omqstat)", ARG3, + PRE_MEM_WRITE( "mq_setattr(omqstat)", ARG3, sizeof(struct vki_mq_attr) ); - } + } } -POST(sys_mq_getsetattr) +POST(sys_kmq_setattr) { if (ARG3 != 0) POST_MEM_WRITE( ARG3, sizeof(struct vki_mq_attr) ); } -#endif - /* --------------------------------------------------------------------- clock_* wrappers ------------------------------------------------------------------ */ @@ -2846,6 +2846,96 @@ ML_(generic_POST_sys_semctl)(tid, RES,ARG1,ARG2,ARG3,ARG4); } +/* --------------------------------------------------------------------- + *POSIX Semaphores + ------------------------------------------------------------------ */ + +PRE(sys_ksem_close) +{ + PRINT("sys_ksem_close( %#lx )", ARG1); + PRE_REG_READ1(int, "ksem_close", vki_semid_t, id); +} + +PRE(sys_ksem_post) +{ + PRINT("sys_ksem_post( %#lx )", ARG1); + PRE_REG_READ1(int, "ksem_post", vki_semid_t, id); + *flags |= SfMayBlock; +} + +PRE(sys_ksem_wait) +{ + PRINT("sys_ksem_wait( %#lx )", ARG1); + PRE_REG_READ1(int, "ksem_wait", vki_semid_t, id); + *flags |= SfMayBlock; +} + +PRE(sys_ksem_trywait) +{ + PRINT("sys_ksem_trywait( %#lx )", ARG1); + PRE_REG_READ1(int, "ksem_trywait", vki_semid_t, id); + *flags |= SfMayBlock; +} + +PRE(sys_ksem_timedwait) +{ + PRINT("sys_ksem_timedwait( %#lx, %#lx )", ARG1, ARG2); + PRE_REG_READ2(int, "ksem_trywait", vki_semid_t, id, const struct timespec *, abstime); + *flags |= SfMayBlock; +} + +PRE(sys_ksem_init) +{ + PRINT("sys_ksem_init( %#lx, %ld )", ARG1, ARG2); + PRE_REG_READ2(int, "ksem_init", vki_semid_t *, idp, + unsigned int, value); + PRE_MEM_WRITE("ksem_init(sem)", ARG1, sizeof(vki_semid_t *)); +} + +POST(sys_ksem_init) +{ + POST_MEM_WRITE(ARG1, sizeof(vki_semid_t *)); +} + +PRE(sys_ksem_open) +{ + PRINT("sys_ksem_open ( %#lx, %#lx(%s), %ld, %ld, %ld )", + ARG1,ARG2,(char*)ARG2,ARG3,ARG4,ARG5); + PRE_REG_READ5(int, "ksem_open", + vki_semid_t *, idp, const char *, name, int, oflag, + vki_mode_t, mode, unsigned int, value); + + PRE_MEM_WRITE("ksem_open(idp)", ARG1, sizeof(vki_semid_t *)); + PRE_MEM_RASCIIZ( "ksem_open(name)", ARG2 ); + + *flags |= SfMayBlock; +} + +POST(sys_ksem_open) +{ + POST_MEM_WRITE(ARG1, sizeof(vki_semid_t *)); +} + +PRE(sys_ksem_unlink) +{ + PRINT("sys_ksem_unlink( %#lx(%s) )", ARG1,(char*)ARG1); + PRE_REG_READ1(int, "ksem_unlink", const char *, name); + PRE_MEM_RASCIIZ( "ksem_unlink(name)", ARG1 ); +} + +PRE(sys_ksem_getvalue) +{ + PRINT("sys_ksem_getvalue ( %#lx, %#lx )", ARG1, ARG2); + PRE_REG_READ2(int, "ksem_unlink", vki_semid_t, id, int *, val); + PRE_MEM_WRITE ("ksem_unlink(val)", ARG2, sizeof (int *)); +} + +PRE(sys_ksem_destroy) +{ + PRINT("sys_ksem_destroy( %#lx )", ARG1); + PRE_REG_READ1(int, "ksem_destroy", vki_semid_t, id); + PRE_MEM_READ("ksem_destroy(sem)", ARG1, sizeof(vki_semid_t)); +} PRE(sys_eaccess) { PRINT("sys_eaccess ( %#lx(%s), %ld )", ARG1,(char*)ARG1,ARG2); @@ -3825,17 +3915,17 @@ BSDXY(__NR_fhstatfs6, sys_fhstatfs6), // 398 // nosys 399 - // ksem_close 400 - // ksem_post 401 - // ksem_wait 402 - // ksem_trywait 403 + BSDX_(__NR_ksem_close, sys_ksem_close), // 400 + BSDX_(__NR_ksem_post, sys_ksem_post), // 401 + BSDX_(__NR_ksem_wait, sys_ksem_wait), // 402 + BSDX_(__NR_ksem_trywait, sys_ksem_trywait), // 403 - // ksem_init 404 - // ksem_open 405 - // ksem_unlink 406 - // ksem_getvalue 407 + BSDXY(__NR_ksem_init, sys_ksem_init), // 404 + BSDXY(__NR_ksem_open, sys_ksem_open), // 405 + BSDX_(__NR_ksem_unlink, sys_ksem_unlink), // 406 + BSDX_(__NR_ksem_getvalue, sys_ksem_getvalue), // 407 - // ksem_destroy 408 + BSDX_(__NR_ksem_destroy, sys_ksem_destroy), // 408 // __mac_get_pid 409 // __mac_get_link 410 // __mac_set_link 411 @@ -3876,7 +3966,7 @@ // extattr_list_link 439 // kse_switchin 440 - // ksem_timedwait 441 + BSDX_(__NR_ksem_timedwait, sys_ksem_timedwait), // 441 // thr_suspend 442 // thr_wake 443 @@ -3896,13 +3986,13 @@ BSDX_(__NR_thr_new, sys_thr_new), // 455 // sigqueue 456 - // kmq_open 457 - // kmq_setattr 458 - // kmq_timedreceive 459 + BSDXY(__NR_kmq_open, sys_kmq_open), // 457 + BSDXY(__NR_kmq_setattr, sys_kmq_setattr), // 458 + BSDXY(__NR_kmq_timedreceive, sys_kmq_timedreceive), // 459 - // kmq_timedsend 460 - // kmq_notify 461 - // kmq_unlink 462 + BSDX_(__NR_kmq_timedsend, sys_kmq_timedsend), // 460 + BSDX_(__NR_kmq_notify, sys_kmq_notify), // 461 + BSDX_(__NR_kmq_unlink, sys_kmq_unlink), // 462 // abort2 463 BSDX_(__NR_thr_set_name, sys_thr_set_name), // 464