Sponsored Content
Full Discussion: Array alignment on HPUX
Top Forums Programming Array alignment on HPUX Post 302145047 by rimon on Monday 12th of November 2007 03:04:45 PM
Old 11-12-2007
Array alignment on HPUX

Hi,

I'm porting code from Windows to HP-UX 11.23, using gcc (I'm begining to suspect this might not be the best choice, but I thought it would be most compatible since we've already compiled on Linux with gcc).

I have in my code something similar to the folowing:
Code:
unsigned char *ch_arr = new (unsigned char)[20];
unsigned char ptr = ch_arr + 10;
unsigned int number = 100;

*((unsigned int *)ptr - 1) = number;

The last line gives a segmentation fault.
In fact, I have found that its enough to write the following in order to crash:
Code:
unsigned char *ch_arr = new (unsigned char)[20];
unsigned int number = 100;

ch_arr[2] = number;

And the same is true for any index in the array which does not divide by 4.
I assume this is an alignment problem. If I were writing new code I could work around it, but since I am porting code this is a problem. Apparently the code uses this type of code, treating char arrays as memory buffers for different types, in many places and it would be very difficult to find them all and fix them.

Is there any compilation flag that could change the alignment for me?
Any other ideas for a global fix for this?

Thanks!

RO
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Column Alignment

I copied a word file to my Unix directory, How do I line up my columns to the file I copied over? (3 Replies)
Discussion started by: nikncha
3 Replies

2. Shell Programming and Scripting

alignment of variable

Dear Champs, i have a file let a.txt having value number text 00 123 012 145 456 ...etc i need number and text column vales should right align ??? how can i achive this ??? NOTE number is of max 3 char and text can take max 7 char...so if any records are less than above lengths... (2 Replies)
Discussion started by: manas_ranjan
2 Replies

3. UNIX for Dummies Questions & Answers

VI paste out of alignment

We have a guy at work who is trying to copy and paste from one file to another using vi and highlighting the code to copy with a mouse. Source file: xyz 123 abc 999 zyx 321 cba 999 xyz 123 abc 999 But when he pastes it he gets (I put the underlines in to show... (4 Replies)
Discussion started by: dlam
4 Replies

4. Shell Programming and Scripting

Need Script to Use CPUs on a HPUX server to simulate Workload Manager on HPUX.

I am running HPUX and using WLM (workload manager). I want to write a script to fork CPUs to basically take CPUs from other servers to show that the communication is working and CPU licensing is working. Basically, I want to build a script that will use up CPU on a server. Any ideas? (2 Replies)
Discussion started by: cpolikowsky
2 Replies

5. Shell Programming and Scripting

alignment

Hi, I am having a file with with format. however, for longer xml, the xml code has been truncated like this. F1 |###################### |String1 |<XML><REQ><MSGTYPE>DBDIRECT</MSGTYPE><SYNC>0</SYNC><CLIENT>C11</CLIENT>NAME=MYNAME|JOB=MYJOB| | ... (3 Replies)
Discussion started by: shellwell
3 Replies

6. HP-UX

HP-UX text alignment

HI all, I tried to edit my files using HP-UX but my output tends to not align when I add another character in the files to edit my files i used the command is as follow chmod +w filename vi filename Help, :eek: (1 Reply)
Discussion started by: jasonhpwong
1 Replies

7. HP-UX

pwage-hpux-T for Trusted HPUX servers

I'm sharing this in case anybody needs it. Modified from the original solaris pwage script. This modified hpux script will check /etc/password file on hpux trusted systems search /tcb and grep the required u_succhg field. Calculate days to expiry and notify users via email. original solaris... (2 Replies)
Discussion started by: sparcguy
2 Replies

8. Shell Programming and Scripting

Row alignment

*1 flash read test(*do_test1*) PASS *2 xxxxxxxxxxx flash write test(*do_test2) FAIL ------>xxxxx *1 flash read test(*do_test1*) PASS *2 xxxxxxxxxxx flash write test(*do_test2) FAIL ------>xxxxx I want pass and Fail to be aligned if each line uses printf or echo to print, is... (5 Replies)
Discussion started by: yanglei_fage
5 Replies

9. UNIX for Beginners Questions & Answers

Help with awk alignment

Dear All, I am in the beginning stage of learning shell scripting and preparing shell script on my own now. I would like to get help from fellow mates here. As I am trying to take O/P with space included from I/P table. Kindly guide me to align given I/P table as Expected O/P. ... (5 Replies)
Discussion started by: Raja007
5 Replies
caca_conio_text_info(3caca)					      libcaca					       caca_conio_text_info(3caca)

NAME
caca_conio_text_info - DOS text area information. SYNOPSIS
Data Fields unsigned char winleft unsigned char wintop unsigned char winright unsigned char winbottom unsigned char attribute unsigned char normattr unsigned char currmode unsigned char screenheight unsigned char screenwidth unsigned char curx unsigned char cury Detailed Description This structure stores text area information for the DOS conio.h compatibility layer. Field Documentation unsigned char caca_conio_text_info::winleft left window coordinate unsigned char caca_conio_text_info::wintop top window coordinate unsigned char caca_conio_text_info::winright right window coordinate unsigned char caca_conio_text_info::winbottom bottom window coordinate unsigned char caca_conio_text_info::attribute text attribute unsigned char caca_conio_text_info::normattr normal attribute unsigned char caca_conio_text_info::currmode current video mode: BW40, BW80, C40, C80, or C4350 unsigned char caca_conio_text_info::screenheight text screen's height unsigned char caca_conio_text_info::screenwidth text screen's width unsigned char caca_conio_text_info::curx x-coordinate in current window unsigned char caca_conio_text_info::cury y-coordinate in current window Author Generated automatically by Doxygen for libcaca from the source code. Version 0.99.beta18 Fri Apr 6 2012 caca_conio_text_info(3caca)
All times are GMT -4. The time now is 12:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy