Files
TheRock/debug-tools/rocgdb/source/gdb/testsuite/gdb.base/bitfields.c
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

218 lines
3.5 KiB
C

/* Test program to test bit field operations */
/* For non-ANSI compilers, use plain ints for the signed bit fields. However,
whether they actually end up signed or not is implementation defined, so
this may cause some tests to fail. But at least we can still compile
the test program and run the tests... */
#if !defined(__STDC__) && !defined(__cplusplus)
#define signed /**/
#endif
struct fields
{
unsigned char uc ;
signed int s1 : 1;
unsigned int u1 : 1;
signed int s2 : 2;
unsigned int u2 : 2;
signed int s3 : 3;
unsigned int u3 : 3;
signed int s9 : 9;
unsigned int u9 : 9;
signed char sc ;
} flags;
struct internalvartest
{
unsigned int a : 1;
struct
{
unsigned int b : 1;
struct
{
unsigned int c : 1;
signed int d : 1;
} deep;
signed int e : 1;
} inner;
signed int f : 1;
} dummy_internalvartest;
void break1 ()
{
}
void break2 ()
{
}
void break3 ()
{
}
void break4 ()
{
}
void break5 ()
{
}
void break6 ()
{
}
void break7 ()
{
}
void break8 ()
{
}
void break9 ()
{
}
void break10 ()
{
}
struct container
{
struct fields one;
struct fields two;
} container;
/* This is used by bitfields.exp to determine if the target understands
signed bitfields. */
int i;
int main ()
{
/* For each member, set that member to 1, allow gdb to verify that the
member (and only that member) is 1, and then reset it back to 0. */
flags.uc = 1;
break1 ();
flags.uc = 0;
flags.s1 = -1;
break1 ();
flags.s1 = 0;
flags.u1 = 1;
break1 ();
flags.u1 = 0;
flags.s2 = 1;
break1 ();
flags.s2 = 0;
flags.u2 = 1;
break1 ();
flags.u2 = 0;
flags.s3 = 1;
break1 ();
flags.s3 = 0;
flags.u3 = 1;
break1 ();
flags.u3 = 0;
flags.s9 = 1;
break1 ();
flags.s9 = 0;
flags.u9 = 1;
break1 ();
flags.u9 = 0;
flags.sc = 1;
break1 ();
flags.sc = 0;
/* Fill alternating fields with all 1's and verify that none of the bits
"bleed over" to the other fields. */
flags.uc = 0xFF;
flags.u1 = 0x1;
flags.u2 = 0x3;
flags.u3 = 0x7;
flags.u9 = 0x1FF;
break2 ();
flags.uc = 0;
flags.u1 = 0;
flags.u2 = 0;
flags.u3 = 0;
flags.u9 = 0;
flags.s1 = -1;
flags.s2 = -1;
flags.s3 = -1;
flags.s9 = -1;
flags.sc = 0xFF;
break2 ();
flags.s1 = 0;
flags.s2 = 0;
flags.s3 = 0;
flags.s9 = 0;
flags.sc = 0;
/* Fill the unsigned fields with the maximum positive value and verify
that the values are printed correctly. */
/* Maximum positive values */
flags.u1 = 0x1;
flags.u2 = 0x3;
flags.u3 = 0x7;
flags.u9 = 0x1FF;
break3 ();
flags.u1 = 0;
flags.u2 = 0;
flags.u3 = 0;
flags.u9 = 0;
/* Fill the signed fields with the maximum positive value, then the maximally
negative value, then -1, and verify in each case that the values are
printed correctly. */
/* Maximum positive values */
flags.s1 = 0x0;
flags.s2 = 0x1;
flags.s3 = 0x3;
flags.s9 = 0xFF;
break4 ();
/* Maximally negative values */
flags.s1 = -0x1;
flags.s2 = -0x2;
flags.s3 = -0x4;
flags.s9 = -0x100;
/* Extract bitfield value so that bitfield.exp can check if the target
understands signed bitfields. */
i = flags.s9;
break4 ();
/* -1 */
flags.s1 = -1;
flags.s2 = -1;
flags.s3 = -1;
flags.s9 = -1;
break4 ();
flags.s1 = 0;
flags.s2 = 0;
flags.s3 = 0;
flags.s9 = 0;
/* Bitfields at a non-zero offset in a containing structure. */
container.one.u3 = 5;
container.two.u3 = 3;
break5 ();
return 0;
}