Changeset ebb1489 in mainline for uspace/lib/c/generic/rndgen.c


Ignore:
Timestamp:
2024-10-13T08:23:40Z (2 months ago)
Author:
GitHub <noreply@…>
Children:
0472cf17
Parents:
2a0c827c (diff), b3b79981 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
boba-buba <120932204+boba-buba@…> (2024-10-13 08:23:40)
git-committer:
GitHub <noreply@…> (2024-10-13 08:23:40)
Message:

Merge branch 'HelenOS:master' into topic/packet-capture

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/rndgen.c

    r2a0c827c rebb1489  
    9292}
    9393
     94/** Generate random 16-bit integer.
     95 *
     96 * @param rndgen Random number generator
     97 * @param rw Place to store random 16-bit integer
     98 * @return EOK on success or error code
     99 */
     100errno_t rndgen_uint16(rndgen_t *rndgen, uint16_t *rw)
     101{
     102        int i;
     103        uint8_t b;
     104        uint16_t w;
     105        errno_t rc;
     106
     107        w = 0;
     108        for (i = 0; i < 2; i++) {
     109                rc = rndgen_uint8(rndgen, &b);
     110                if (rc != EOK)
     111                        return rc;
     112
     113                w = (w << 8) | b;
     114        }
     115
     116        *rw = w;
     117        return EOK;
     118}
     119
    94120/** Generate random 32-bit integer.
    95121 *
Note: See TracChangeset for help on using the changeset viewer.