Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #142762
| From | Ike Naar <ike@iceland.freeshell.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: memcpy or assign data to uint64 on little endian(linux) system |
| Date | 2019-04-03 06:14 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrn3t4oqa8jpn.j6n.ike@iceland.freeshell.org> (permalink) |
| References | <3b06fd96-348b-423c-af57-e44e1f79b40c@googlegroups.com> <e7i8ae1tc2d5n01e6gsgahck4dinccsh1j@4ax.com> |
On 2019-04-03, Geoff <geoff@invalid.invalid> wrote:
> On Tue, 2 Apr 2019 18:14:31 -0700 (PDT), WalkeR Park
><walker.ykpark@gmail.com> wrote:
>
>>Hi,
>>I'm just porting some source that is written from HP-UX to the linux.
>>AKA, HP is Big-Endian and liunx is Little-Endian.
>>
>>In source of HP, threa are many memcpy, and Assign Data Source...
>>Porting is OK, but In that case "memcpy or assign data to uint64",
>>Data is stored reversely.
>>
>>ex)
>>=================================================
>> uint64 a;
>> char b[8] = {0x38, 0x12, 0x12, 0x12, 0x81, 0x28, 0x28, 0x28};
>> memcpy(&a, b, 8);
>> printf("TEST [%lu]\n", a);
>>=================================================
>>
>>I know that Just using and adjusting htonll or htonl whatnot...
>>But Source is huge scale, so I'm not able to Every code line that I'm gonna find.
>>
>>Is there any solution using kernel setting and so on but changing every source code line?
>>
>>regards.
>
> Consider writing a reversing memmove (r_memmove) then
> #define memcpy r_memmove
> for the sections where this is needed.
>
> Prefer memmove over memcpy.
Or consider initializing a as
uint64_t a = 0x3812121281282828;
This should behave the same on big-endian and little-endian machines.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
memcpy or assign data to uint64 on little endian(linux) system WalkeR Park <walker.ykpark@gmail.com> - 2019-04-02 18:14 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system Geoff <geoff@invalid.invalid> - 2019-04-02 22:49 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system Ike Naar <ike@iceland.freeshell.org> - 2019-04-03 06:14 +0000
Re: memcpy or assign data to uint64 on little endian(linux) system Geoff <geoff@invalid.invalid> - 2019-04-02 23:22 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-03 11:07 +0100
Re: memcpy or assign data to uint64 on little endian(linux) system Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-04-03 12:56 +0000
Re: memcpy or assign data to uint64 on little endian(linux) system fir <profesor.fir@gmail.com> - 2019-04-03 06:52 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-03 16:06 +0100
Re: memcpy or assign data to uint64 on little endian(linux) system fir <profesor.fir@gmail.com> - 2019-04-03 04:03 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system fir <profesor.fir@gmail.com> - 2019-04-03 04:13 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-04-03 12:37 +0000
Re: memcpy or assign data to uint64 on little endian(linux) system Ike Naar <ike@iceland.freeshell.org> - 2019-04-03 16:10 +0000
Re: memcpy or assign data to uint64 on little endian(linux) system Keith Thompson <kst-u@mib.org> - 2019-04-03 12:50 -0700
csiph-web