Skip to content

Commit 2c5f602

Browse files
committed
Add support to Alpine (stderr)
1 parent 0c44ef6 commit 2c5f602

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

.github/docker/alpine-3.20.Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
#
6+
# Dockerfile - a 'recipe' for Docker to build an image of Alpine
7+
# environment for building the Unified Memory Framework project.
8+
#
9+
10+
# Pull base Alpine image version 3.20
11+
FROM alpine:3.20
12+
13+
# Set environment variables
14+
ENV OS alpine
15+
ENV OS_VER 3.20
16+
17+
# Base development packages
18+
ARG BASE_DEPS="\
19+
cmake \
20+
git \
21+
g++ \
22+
make"
23+
24+
# UMF's dependencies
25+
ARG UMF_DEPS="\
26+
hwloc-dev"
27+
28+
# Add a new (non-root) 'test_user'
29+
ENV USER test_user
30+
ENV USERPASS pass
31+
RUN useradd -m "${USER}" -g sudo -p "$(mkpasswd ${USERPASS})"
32+
USER test_user
33+
34+
# Update and install required packages
35+
RUN apk update \
36+
&& apk add \
37+
${BASE_DEPS} \
38+
${UMF_DEPS}
39+
40+
# clone the repository
41+
RUN git clone https://github.com/oneapi-src/unified-memory-framework.git
42+
43+
# build the project
44+
RUN cd unified-memory-framework \
45+
cmake -B build -DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_TESTS=ON -DUMF_BUILD_EXAMPLES=OFF \
46+
cmake --build build

src/utils/utils_log.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2024 Intel Corporation
3+
* Copyright (C) 2024-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -10,7 +10,6 @@
1010
#ifdef _WIN32
1111
#include <windows.h>
1212
#else
13-
#define _GNU_SOURCE 1
1413
#include <sys/syscall.h>
1514
#include <sys/types.h>
1615
#include <unistd.h>
@@ -153,13 +152,21 @@ static void utils_log_internal(utils_log_level_t level, int perror,
153152
}
154153
errno = saveno;
155154
#else
156-
char err_buff[1024]; // max size according to manpage.
157155
int saveno = errno;
158156
errno = 0;
157+
#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE
158+
char err[1024];
159+
int err_ret = strerror_r(saveno, err, sizeof(err));
160+
if (err_ret == ERANGE) {
161+
postfix = "[truncated...]";
162+
}
163+
#else
164+
char err_buff[1024]; // max size according to manpage.
159165
const char *err = strerror_r(saveno, err_buff, sizeof(err_buff));
160166
if (errno == ERANGE) {
161167
postfix = "[truncated...]";
162168
}
169+
#endif
163170
errno = saveno;
164171
#endif
165172
strncpy(b_pos, err, b_size);

0 commit comments

Comments
 (0)