File:  [CSRG BSD Unix] / 43BSDReno / pgrm / dbx / tests / cc / bitfields.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:57 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43reno
BSD 4.3reno

typedef unsigned int uint;

struct dot {
    uint  cost		 :24;
    uint  type	         : 3;
    uint  dirToCenter	 : 3;
    uint  pad		 : 1;
    uint  pin		 : 1;
    uint  traceback	 : 3;
    uint  traceforward   : 3;
    uint  expanded	 : 1;
    uint  underDir	 : 3;
    uint  underOffset	 : 4;
    uint  start		 : 1;
    uint  target	 : 1;
    uint  owner		 : 6;
    uint  segment	 : 7;
    uint  intrinsicCost  : 3;
};

main()
{
    struct dot junk;

    junk.owner = 63;
    junk.segment = 1;
    junk.intrinsicCost = 1;

    printf("owner = %d, segment = %d, intrinsicCost = %d\n",
	junk.owner, junk.segment, junk.intrinsicCost);
    printf("done\n");
    oldmain();
}

oldmain()
{
    struct {
	int first;
	int second;
	int a : 8;
	int b : 8;
	int c;
    } x;

    x.first = 0;
    x.second = 0;
    x.a = 2;
    x.b = 10;
    x.c = 1;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.