if (retcode == 0) {
return 0;
} else {
- errno = retcode;
+ *(__errno_location()) = retcode;
return -1;
}
}
(int)(&nanosleep_interval), (int)NULL);
}
- * (__errno_location()) = EINTR;
+ *(__errno_location()) = EINTR;
return -1;
}
static struct __res_state
thread_specific_res_state[VG_N_THREADS];
+#undef errno
+extern int errno;
int* __errno_location ( void )
{
int tid;
/* 'cos I'm paranoid ... */
if (tid < 1 || tid >= VG_N_THREADS)
barf("__errno_location: invalid ThreadId");
+ if (tid == 1)
+ return &errno;
return & thread_specific_errno[tid];
}
+#undef h_errno
+extern int h_errno;
int* __h_errno_location ( void )
{
int tid;
/* 'cos I'm paranoid ... */
if (tid < 1 || tid >= VG_N_THREADS)
barf("__h_errno_location: invalid ThreadId");
+ if (tid == 1)
+ return &h_errno;
return & thread_specific_h_errno[tid];
}
#undef _res
extern struct __res_state _res;
-
struct __res_state* __res_state ( void )
{
int tid;
if (flags & VKI_O_NONBLOCK)
return fd;
- saved_errno = errno;
+ saved_errno = *(__errno_location());
if (fd != -1)
break; /* open worked */
/* If we got ENXIO and we're opening WRONLY, and it turns out
to really be a FIFO, then poll waiting for open to succeed */
- if (errno == ENXIO &&
+ if (*(__errno_location()) == ENXIO &&
(flags & VKI_O_ACCMODE) == VKI_O_WRONLY &&
(stat(pathname, &st) == 0 && S_ISFIFO(st.st_mode))) {
(int)(&nanosleep_interval), (int)NULL);
} else {
/* it was just an error */
- errno = saved_errno;
+ *(__errno_location()) = saved_errno;
return -1;
}
}
*/
if ((flags & VKI_O_ACCMODE) != VKI_O_RDONLY ||
(fstat(fd, &st) == -1 || !S_ISFIFO(st.st_mode))) {
- errno = saved_errno;
+ *(__errno_location()) = saved_errno;
return fd;
}
(int)(&nanosleep_interval), (int)NULL);
}
- errno = saved_errno;
+ *(__errno_location()) = saved_errno;
return fd;
}
ensure_valgrind("sem_init");
if (pshared != 0) {
pthread_error("sem_init: unsupported pshared value");
- errno = ENOSYS;
+ *(__errno_location()) = ENOSYS;
return -1;
}
vg_sem = se_remap(sem);
ret = 0;
} else {
ret = -1;
- errno = EAGAIN;
+ *(__errno_location()) = EAGAIN;
}
res = __pthread_mutex_unlock(&vg_sem->se_mx);
my_assert(res == 0);
if (retcode == 0) {
return 0;
} else {
- errno = retcode;
+ *(__errno_location()) = retcode;
return -1;
}
}
(int)(&nanosleep_interval), (int)NULL);
}
- * (__errno_location()) = EINTR;
+ *(__errno_location()) = EINTR;
return -1;
}
static struct __res_state
thread_specific_res_state[VG_N_THREADS];
+#undef errno
+extern int errno;
int* __errno_location ( void )
{
int tid;
/* 'cos I'm paranoid ... */
if (tid < 1 || tid >= VG_N_THREADS)
barf("__errno_location: invalid ThreadId");
+ if (tid == 1)
+ return &errno;
return & thread_specific_errno[tid];
}
+#undef h_errno
+extern int h_errno;
int* __h_errno_location ( void )
{
int tid;
/* 'cos I'm paranoid ... */
if (tid < 1 || tid >= VG_N_THREADS)
barf("__h_errno_location: invalid ThreadId");
+ if (tid == 1)
+ return &h_errno;
return & thread_specific_h_errno[tid];
}
#undef _res
extern struct __res_state _res;
-
struct __res_state* __res_state ( void )
{
int tid;
if (flags & VKI_O_NONBLOCK)
return fd;
- saved_errno = errno;
+ saved_errno = *(__errno_location());
if (fd != -1)
break; /* open worked */
/* If we got ENXIO and we're opening WRONLY, and it turns out
to really be a FIFO, then poll waiting for open to succeed */
- if (errno == ENXIO &&
+ if (*(__errno_location()) == ENXIO &&
(flags & VKI_O_ACCMODE) == VKI_O_WRONLY &&
(stat(pathname, &st) == 0 && S_ISFIFO(st.st_mode))) {
(int)(&nanosleep_interval), (int)NULL);
} else {
/* it was just an error */
- errno = saved_errno;
+ *(__errno_location()) = saved_errno;
return -1;
}
}
*/
if ((flags & VKI_O_ACCMODE) != VKI_O_RDONLY ||
(fstat(fd, &st) == -1 || !S_ISFIFO(st.st_mode))) {
- errno = saved_errno;
+ *(__errno_location()) = saved_errno;
return fd;
}
(int)(&nanosleep_interval), (int)NULL);
}
- errno = saved_errno;
+ *(__errno_location()) = saved_errno;
return fd;
}
ensure_valgrind("sem_init");
if (pshared != 0) {
pthread_error("sem_init: unsupported pshared value");
- errno = ENOSYS;
+ *(__errno_location()) = ENOSYS;
return -1;
}
vg_sem = se_remap(sem);
ret = 0;
} else {
ret = -1;
- errno = EAGAIN;
+ *(__errno_location()) = EAGAIN;
}
res = __pthread_mutex_unlock(&vg_sem->se_mx);
my_assert(res == 0);