# US 8,578,357 B2 · Endian conversion tool

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 8,578,357 B2
- Document ID: US8578357B2
- Status: Granted
- Kind: B2
- Application number: 12/643,216
- Filed: 2009-12-21
- Published: 2011-06-23
- Granted: 2013-11-05
- Earliest claimed: 2009-12-21
- Assignees: Intel Corporation
- Applicants: Michael P. Rice; Hugh Wilkinson; Maximillian J. Domeika; Evgueni V. Brevnov; Peter Lachner
- Inventors: Michael P. Rice; Hugh Wilkinson; Maximillian J. Domeika; Evgueni V. Brevnov; Peter Lachner
- Web page: https://patentgrep.com/patent/US8578357B2

## CPC

- G06F 8/447: {Target code generation}
- G06F 8/44: {Encoding}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

In one embodiment of the invention code (e.g., compiler, tool) may generate information so a first code portion, which includes a pointer value in a first endian format (e.g., big endian), can be properly initialized and executed on a platform having a second endian format (e.g., little endian). Also, various embodiments of the invention may identify problematic regions of code (e.g., source code) where a particular byte order is cast away through void pointers.

## Claims

### Claim 1

A method comprising:
receiving first and second source code portions that respectively define first and second instances of a global variable, wherein each instance has a first endian format and neither instance can be fully initialized at compile time;
generating first and second references to byteswap instructions configured to respectively convert the first and second instances to a second endian format;
generating, using a processor, a shadow variable configured to suppress a byteswap of the second instance after compile time and based on the first instance having been byteswapped; and
storing the shadow variable in a memory coupled to the processor.

### Claim 2 (depends on 1)

The method of claim 1, wherein neither instance can be fully initialized at compile time based on the global variable being a pointer having the first endian format.

### Claim 3 (depends on 2)

The method of claim 2, wherein the shadow variable is configured to indicate whether the first instance is byteswapped.

### Claim 4 (depends on 2)

The method of claim 2, wherein the shadow variable is configured to suppress the byteswap of the second instance based on the shadow variable having been converted from a weakly defined variable to a strongly defined variable.

### Claim 5 (depends on 2)

The method of claim 2 including generating compiled code having both first and second endian formats.

### Claim 6 (depends on 2)

The method of claim 2 including generating a guard variable configured to determine, at run time and after initialization of the guard, variable, the guard variable has been byte converted, wherein the guard variable is to be initialized with a known link time constant.

### Claim 7 (depends on 2)

The method of claim 2, wherein the first and second instances are configured to be initialized, after compile time, based respectively on first and second link time constants each having the first endian format.

### Claim 8 (depends on 1)

The method of claim 1 including:
receiving a third source code portion that includes a void pointer;
tracking byte order through the void pointer; and
determining a byte order mismatch occurred based on the void pointer.

### Claim 9 (depends on 1)

The method of claim 1 including: receiving a third source code portion that includes a void pointer;
tracking data size through the void pointer; and
determining a data size mismatch occurred based on the void pointer.

### Claim 10

An article comprising a non-transitory storage medium storing instructions that enable a processor-based system to:
receive first and second code portions that respectively define first and second instances of a global variable, wherein each instance of the global variable has a first endian format and neither instance can be correctly initialized at compile time; and
generate a first variable configured to suppress endian conversion of the second instance after compile time and based on the first instance having been endian converted.

### Claim 11 (depends on 10)

The article of claim 10, wherein the global variable is a pointer.

### Claim 12 (depends on 11)

The article of claim 11, further storing instructions that enable the system to relocate the first variable based on information generated from a compiler, wherein the first variable is configured to suppress the endian conversion of the second instance based on the relocation.

### Claim 13 (depends on 11)

The article of claim 11, wherein the first instance is based on an address of a second global variable.

### Claim 14 (depends on 11)

The article of claim 11, wherein the first and second code portions are configured to be linked dynamically.

### Claim 15 (depends on 10)

The article of claim 10, further storing instructions that enable the system to:
receive a third code portion that includes a void pointer;
track byte order through the void pointer; and
determine a byte order mismatch occurred based on the void pointer.

### Claim 16

An apparatus comprising:
a processor, coupled to a memory, to:
(1) receive, using the memory, first and second source code portions that respectively define first and second instances of a global variable, wherein each instance of the global variable has a first endian format and neither instance can be fully initialized at compile time; and
(2) generate a first variable configured to suppress a byteswap of the second instance after compile time and based on the first instance having been byteswapped.

### Claim 17 (depends on 16)

The apparatus of claim 16, wherein the global variable is a pointer.

### Claim 18 (depends on 17)

The apparatus of claim 17, wherein the first variable is configured to suppress the byteswap of the second instance based on the first variable having been converted from a weakly defined variable to a strongly defined variable.

### Claim 19 (depends on 17)

The apparatus of claim 17, wherein the first and second code portions are configured to be linked dynamically.

### Claim 20 (depends on 16)

The apparatus of claim 16, wherein the processor is to: receive a third source code portion that includes a void pointer; track byte order through the void pointer; and determine a byte order mismatch occurred based on the void pointer.
