summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphantom <phantom@FreeBSD.org>2003-02-03 10:08:45 +0000
committerphantom <phantom@FreeBSD.org>2003-02-03 10:08:45 +0000
commit263e2476e49a1922267fc32e3a903c3825035049 (patch)
treeb2102f390b02be7c6ec90403e5b950753ef3e7de
parent2f3f171cbe1c151b0e4713cf0cb986c6cdfe87fb (diff)
downloadFreeBSD-src-263e2476e49a1922267fc32e3a903c3825035049.zip
FreeBSD-src-263e2476e49a1922267fc32e3a903c3825035049.tar.gz
Improve pthread_attr_get_np() by enabling it to return thread's real stack
address instead of specified by pthread_attr_t passed to pthread_create(). Suggested by: deischen
-rw-r--r--lib/libc_r/uthread/uthread_attr_get_np.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libc_r/uthread/uthread_attr_get_np.c b/lib/libc_r/uthread/uthread_attr_get_np.c
index a427f79..ba6fd19 100644
--- a/lib/libc_r/uthread/uthread_attr_get_np.c
+++ b/lib/libc_r/uthread/uthread_attr_get_np.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002 Alexey Zelkin <phantom@FreeBSD.org>
+ * Copyright (c) 2002,2003 Alexey Zelkin <phantom@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,5 +45,13 @@ _pthread_attr_get_np(pthread_t pid, pthread_attr_t *dst)
return (ret);
memcpy(*dst, &pid->attr, sizeof(struct pthread_attr));
+
+ /*
+ * Special case, if stack address was not provided by caller
+ * of pthread_create(), then return address allocated internally
+ */
+ if ((*dst)->stackaddr_attr == NULL)
+ (*dst)->stackaddr_attr = pid->stack;
+
return (0);
}
OpenPOWER on IntegriCloud