How to concatenate four integers in one array in kernel?

luminousmen

I have two 32-bit integers and two 16-bit integers. How can I combine them into one 12-byte long array in the kernel?

linzuojian
char a[12];
char* b = &a[0];
int* c = (int*)b;
c[0] = n1;
c[1] = n2;
short* d = (short*)(b + 8);
d[0] = s1;
d[1] = s2;

Edit: when these statments stay in a function then there will be no strict aliasing problem.

Additionally if you want to learn more about aliasing find this function from GCC's source: c_common_get_alias_set

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to concatenate "$@" or array to one string

How to Concatenate integers in BigQuery?

Numpy array: concatenate arrays and integers

How to concatenate and print a list of integers?

How to concatenate two integers in Python?

How to concatenate two integers in Kotlin?

How to concatenate string array field to show as one string if its an array

How to read tetrads (groups of four integers) and save it in 2d array?

How to concatenate 2 or more strings as one inside a string array in Java?

JavaScript: How to join / combine two arrays to concatenate into one array?

how to concatenate multiple Array of Strings into one single String in Scala

How to concatenate one element with other across rows in a cell array?

How to store two integers in one array (C++)

How to find biggest out of four integers?

concatenate a part of two array in one

Four integers in four bytes?

How to consecutively concatenate a vector of integers in R

How to concatenate vector of integers interleaving elements with a character?

how to concatenate two positive integers using macros?

Filling an array of integers by one prompting

How to concatenate elements into an array?

How to concatenate an HTMLCollection with an array?

How to concatenate a derived array

how to CONCATENATE array text?

How to concatenate this array

How to concatenate lists into one list

How to add integers from one two dimensional array and create a new two dimensional array

concatenate array of images together in one sourcefile

concatenate multiple numpy arrays in one array?