PostgreSQL Source Code git master
Loading...
Searching...
No Matches
explicit_bzero.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * explicit_bzero.c
4 *
5 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
6 * Portions Copyright (c) 1994, Regents of the University of California
7 *
8 *
9 * IDENTIFICATION
10 * src/port/explicit_bzero.c
11 *
12 *-------------------------------------------------------------------------
13 */
14
15#define __STDC_WANT_LIB_EXT1__ 1 /* needed to access memset_s() */
16
17#include "c.h"
18
19#if defined(HAVE_MEMSET_EXPLICIT)
20
21void
22explicit_bzero(void *buf, size_t len)
23{
25}
26
27#elif defined(HAVE_EXPLICIT_MEMSET)
28
29void
30explicit_bzero(void *buf, size_t len)
31{
33}
34
35#elif HAVE_DECL_MEMSET_S
36
37void
38explicit_bzero(void *buf, size_t len)
39{
40 (void) memset_s(buf, len, 0, len);
41}
42
43#elif defined(WIN32)
44
45void
46explicit_bzero(void *buf, size_t len)
47{
49}
50
51#else
52
53/*
54 * Indirect call through a volatile pointer to hopefully avoid dead-store
55 * optimisation eliminating the call. (Idea taken from OpenSSH.) We can't
56 * assume bzero() is present either, so for simplicity we define our own.
57 */
58
59static void
60bzero2(void *buf, size_t len)
61{
62 memset(buf, 0, len);
63}
64
65static void (*volatile bzero_p) (void *, size_t) = bzero2;
66
67void
68explicit_bzero(void *buf, size_t len)
69{
70 bzero_p(buf, len);
71}
72
73#endif
static void(*volatile bzero_p)(void *, size_t)
void explicit_bzero(void *buf, size_t len)
static void bzero2(void *buf, size_t len)
const void size_t len
static char buf[DEFAULT_XLOG_SEG_SIZE]
static int fb(int x)