J
jcitrix
Hi folks,
I'm looking at a problem that has been bugging me for a few days.
It's an forum question/problem that was posted by a reader and I can't
get my head around it. I've tried my due diligence to look this up
myself, but without knowing what the beast is I can't seem to form the
right query. So, now I'm here asking in hopes that the "human touch"
will prove more fruitful. Of course, I shudder to post anything to
c.l.c in fear of being called out as off topic. I certainly didn't
plan on that.
The code is to set up the global descriptor table for the x86
processor (but that's only details)...
Here's what I'm looking at (I've edited so I could get to the point):
struct Segdesc gdt[] =
{
[GD_KT >> 3] = yadda_yadda_yadda; /* this is the confusing
part */
};
/* what's with the bit shift on the left of the assignment operator??
my impression is 'undefined' or 'non-ISO'. */
struct Segdesc {
unsigned sd_lim_15_0 : 16; // Low bits of segment limit
unsigned sd_base_15_0 : 16; // Low bits of segment base address
unsigned sd_base_23_16 : 8; // Middle bits of segment base address
unsigned sd_type : 4; // Segment type (see STS_ constants)
unsigned sd_s : 1; // 0 = system, 1 = application
unsigned sd_dpl : 2; // Descriptor Privilege Level
unsigned sd_p : 1; // Present
unsigned sd_lim_19_16 : 4; // High bits of segment limit
unsigned sd_avl : 1; // Unused (available for software use)
unsigned sd_rsv1 : 1; // Reserved
unsigned sd_db : 1; // 0 = 16-bit segment, 1 = 32-bit
segment
unsigned sd_g : 1; // Granularity: limit scaled by 4K when
set
unsigned sd_base_31_24 : 8; // High bits of segment base address
};
If anyone can help me understand what the bit shift would do on the
left of an assignment (or point me in the direction of enlightenment)
I would be grateful. The OP in the forum said that this was an
"associated array type of structure". In Perl speak (<puts on flame-
retardant underwear>), this would be a hash, but that's not a
structure native to C and one would have to roll their own (or use a
third-party library)...
Or am I just totally off the reservation on this?
Cheers!
I'm looking at a problem that has been bugging me for a few days.
It's an forum question/problem that was posted by a reader and I can't
get my head around it. I've tried my due diligence to look this up
myself, but without knowing what the beast is I can't seem to form the
right query. So, now I'm here asking in hopes that the "human touch"
will prove more fruitful. Of course, I shudder to post anything to
c.l.c in fear of being called out as off topic. I certainly didn't
plan on that.
The code is to set up the global descriptor table for the x86
processor (but that's only details)...
Here's what I'm looking at (I've edited so I could get to the point):
struct Segdesc gdt[] =
{
[GD_KT >> 3] = yadda_yadda_yadda; /* this is the confusing
part */
};
/* what's with the bit shift on the left of the assignment operator??
my impression is 'undefined' or 'non-ISO'. */
struct Segdesc {
unsigned sd_lim_15_0 : 16; // Low bits of segment limit
unsigned sd_base_15_0 : 16; // Low bits of segment base address
unsigned sd_base_23_16 : 8; // Middle bits of segment base address
unsigned sd_type : 4; // Segment type (see STS_ constants)
unsigned sd_s : 1; // 0 = system, 1 = application
unsigned sd_dpl : 2; // Descriptor Privilege Level
unsigned sd_p : 1; // Present
unsigned sd_lim_19_16 : 4; // High bits of segment limit
unsigned sd_avl : 1; // Unused (available for software use)
unsigned sd_rsv1 : 1; // Reserved
unsigned sd_db : 1; // 0 = 16-bit segment, 1 = 32-bit
segment
unsigned sd_g : 1; // Granularity: limit scaled by 4K when
set
unsigned sd_base_31_24 : 8; // High bits of segment base address
};
If anyone can help me understand what the bit shift would do on the
left of an assignment (or point me in the direction of enlightenment)
I would be grateful. The OP in the forum said that this was an
"associated array type of structure". In Perl speak (<puts on flame-
retardant underwear>), this would be a hash, but that's not a
structure native to C and one would have to roll their own (or use a
third-party library)...
Or am I just totally off the reservation on this?
Cheers!