| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include <stdint.h> |
| 20 |
#include <sys/prctl.h> |
| 21 |
#include <support/check.h> |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
typedef union |
| 26 |
{ |
| 27 |
struct |
| 28 |
{ |
| 29 |
union |
| 30 |
{ |
| 31 |
const char *ptr; |
| 32 |
int i1; |
| 33 |
}; |
| 34 |
int i2; |
| 35 |
} s; |
| 36 |
long long ll; |
| 37 |
} parameter_t; |
| 38 |
|
| 39 |
static int |
| 40 |
__attribute__ ((noipa)) |
| 41 |
do_prctl (int op, long long arg1, long long arg2, long long arg3, |
| 42 |
long long arg4) |
| 43 |
{ |
| 44 |
return prctl (op, arg1, arg2, arg3, arg4); |
| 45 |
} |
| 46 |
|
| 47 |
static int |
| 48 |
do_test (void) |
| 49 |
{ |
| 50 |
parameter_t name = { { { "thread name" }, -1 } }; |
| 51 |
parameter_t zero = { { { 0 }, -2 } }; |
| 52 |
TEST_COMPARE (do_prctl (PR_SET_NAME, name.ll, zero.ll, zero.ll, |
| 53 |
zero.ll), 0); |
| 54 |
char buffer[16] = { 0, }; |
| 55 |
name.s.ptr = buffer; |
| 56 |
TEST_COMPARE (do_prctl (PR_GET_NAME, name.ll, zero.ll, zero.ll, |
| 57 |
zero.ll), 0); |
| 58 |
char expected[16] = "thread name"; |
| 59 |
TEST_COMPARE_BLOB (buffer, sizeof (buffer), expected, sizeof (expected)); |
| 60 |
return 0; |
| 61 |
} |
| 62 |
|
| 63 |
#include <support/test-driver.c> |