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
hwloc_topology_membind_support(3)			     Hardware Locality (hwloc)				 hwloc_topology_membind_support(3)

NAME
hwloc_topology_membind_support - SYNOPSIS
#include <hwloc.h> Data Fields unsigned char set_thisproc_membind unsigned char get_thisproc_membind unsigned char set_proc_membind unsigned char get_proc_membind unsigned char set_thisthread_membind unsigned char get_thisthread_membind unsigned char set_area_membind unsigned char get_area_membind unsigned char alloc_membind unsigned char firsttouch_membind unsigned char bind_membind unsigned char interleave_membind unsigned char replicate_membind unsigned char nexttouch_membind unsigned char migrate_membind Detailed Description Flags describing actual memory binding support for this topology. Field Documentation unsigned char hwloc_topology_membind_support::alloc_membind Allocating a bound memory area is supported. unsigned char hwloc_topology_membind_support::bind_membind Bind policy is supported. unsigned char hwloc_topology_membind_support::firsttouch_membind First-touch policy is supported. unsigned char hwloc_topology_membind_support::get_area_membind Getting the binding of a given memory area is supported. unsigned char hwloc_topology_membind_support::get_proc_membind Getting the binding of a whole given process is supported. unsigned char hwloc_topology_membind_support::get_thisproc_membind Getting the binding of the whole current process is supported. unsigned char hwloc_topology_membind_support::get_thisthread_membind Getting the binding of the current thread only is supported. unsigned char hwloc_topology_membind_support::interleave_membind Interleave policy is supported. unsigned char hwloc_topology_membind_support::migrate_membind Migration flags is supported. unsigned char hwloc_topology_membind_support::nexttouch_membind Next-touch migration policy is supported. unsigned char hwloc_topology_membind_support::replicate_membind Replication policy is supported. unsigned char hwloc_topology_membind_support::set_area_membind Binding a given memory area is supported. unsigned char hwloc_topology_membind_support::set_proc_membind Binding a whole given process is supported. unsigned char hwloc_topology_membind_support::set_thisproc_membind Binding the whole current process is supported. unsigned char hwloc_topology_membind_support::set_thisthread_membind Binding the current thread only is supported. Author Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code. Version 1.4.1 Mon Feb 27 2012 hwloc_topology_membind_support(3)
All times are GMT -4. The time now is 09:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy