- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to pack structures on HPUX PA RISC64
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2021 07:21 PM - last edited on 08-06-2021 02:15 AM by support_s
07-07-2021 07:21 PM - last edited on 08-06-2021 02:15 AM by support_s
How to pack structures on HPUX PA RISC64
Dear All,
For understanding the PACKED STRUCTURES on HPUX, I wrote the below program and executed on HPUX PA RISC 64 11.31 machine.
bash-4.3$ cat abc.c
#include <stdio.h>
/* BEGIN THE PACK */
#pragma pack(1)
typedef union
{
char a[6];
int ab[1];
} abc_packed;
#pragma pack()
/* END THE PACK */
typedef union
{
char a[6];
int ab[1];
} abc_unpacked;
main()
{
printf("sizeof(abc_packed) is: %d sizeof(int) is %d sizeof(char) is %d\n",
sizeof(abc_packed), sizeof(int), sizeof(char));
printf("sizeof(abc_unpacked) is: %d\n ", sizeof(abc_unpacked));
}
bash-4.3$
bash-4.3$ ./a.out
sizeof(abc_packed) is: 8 sizeof(int) is 4 sizeof(char) is 1
sizeof(abc_unpacked) is: 8
bash-4.3$
Interstingly the size of both packed and unpacked unions is same.
On other Operating System, for packed unions the size is 6 bytes for unpacked unions it is 8 bytes.
For me it looks like, In the above code, the preprocessor macro "#pragma pack(1)" has no effect on HPUX PA RISC64 machine.
Is there any other option for packing structures/unions on HPUX PA RISC?
Thanks,
- Tags:
- Operating System
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2021 09:51 PM
07-07-2021 09:51 PM
Re: How to pack structures on HPUX PA RISC64
> [...] executed on HPUX PA RISC 64 11.31 machine.
> On other Operating System, [...]
But before you executed anything, you compiled it first, right?
Using what? This is less a hardware or OS question than it is a
compiler question.
> Is there any other option for packing structures/unions on HPUX PA
> RISC?
If you're using some (intentionally crippled) "bundled" compiler,
then you might try using some real compiler.
Your bundled compiler might be better than mine, but perhaps not much
better. Of course, with my weak psychic powers, I can't see your work.
dy $ uname -a
HP-UX dy B.11.11 U 9000/785 2012616114 unlimited-user license
dy $ cc -o pack_cc pack.c
(Bundled) cc: "pack.c", line 4: warning 42: The "PACK" pragma needs an
integer argument.
(Bundled) cc: "pack.c", line 10: warning 42: The "PACK" pragma needs an
integer argument.
dy $ gcc -o pack_gcc pack.c
dy $ ./pack_cc
sizeof(abc_packed) is: 8 sizeof(int) is 4 sizeof(char) is 1
sizeof(abc_unpacked) is: 8
dy $ ./pack_gcc
sizeof(abc_packed) is: 6 sizeof(int) is 4 sizeof(char) is 1
sizeof(abc_unpacked) is: 8
There's much to be said for naturally aligned structures, I claim.