Home / File/ netty_unix_errors.c — netty Source File

netty_unix_errors.c — netty Source File

Architecture documentation for netty_unix_errors.c, a c file in the netty codebase. 8 imports, 0 dependents.

File c NativeTransport 8 imports

Entity Profile

Dependency Diagram

graph LR
  b538e79f_f5cb_cc60_5a77_6b2382df83f1["netty_unix_errors.c"]
  a4533dad_6113_0c5b_b279_28eaf7391fc5["netty_unix_errors.h"]
  b538e79f_f5cb_cc60_5a77_6b2382df83f1 --> a4533dad_6113_0c5b_b279_28eaf7391fc5
  a7d65015_0594_5090_5390_74fe05dfdd3e["netty_unix_jni.h"]
  b538e79f_f5cb_cc60_5a77_6b2382df83f1 --> a7d65015_0594_5090_5390_74fe05dfdd3e
  e811edce_3305_6244_830c_daac1b109259["netty_unix_util.h"]
  b538e79f_f5cb_cc60_5a77_6b2382df83f1 --> e811edce_3305_6244_830c_daac1b109259
  89cfd132_669d_bc14_f916_80a38e3da8a5["netty_jni_util.h"]
  b538e79f_f5cb_cc60_5a77_6b2382df83f1 --> 89cfd132_669d_bc14_f916_80a38e3da8a5
  5cbcd069_b25c_7379_e9c5_47a7dd85985a["string.h"]
  b538e79f_f5cb_cc60_5a77_6b2382df83f1 --> 5cbcd069_b25c_7379_e9c5_47a7dd85985a
  d822c438_bcda_8ebc_05f9_1007c55018be["stdlib.h"]
  b538e79f_f5cb_cc60_5a77_6b2382df83f1 --> d822c438_bcda_8ebc_05f9_1007c55018be
  71c52c20_b4aa_1551_58db_42e42fa27aa6["errno.h"]
  b538e79f_f5cb_cc60_5a77_6b2382df83f1 --> 71c52c20_b4aa_1551_58db_42e42fa27aa6
  0c4a58dc_2fdd_e4ad_9234_08a5790f43e3["jni.h"]
  b538e79f_f5cb_cc60_5a77_6b2382df83f1 --> 0c4a58dc_2fdd_e4ad_9234_08a5790f43e3
  style b538e79f_f5cb_cc60_5a77_6b2382df83f1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/*
 * Copyright 2015 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <jni.h>
#include "netty_unix_errors.h"
#include "netty_unix_jni.h"
#include "netty_unix_util.h"
#include "netty_jni_util.h"

#define ERRORS_CLASSNAME "io/netty/channel/unix/ErrorsStaticallyReferencedJniMethods"

static jweak channelExceptionClassWeak = NULL;
static jclass oomErrorClass = NULL;
static jclass runtimeExceptionClass = NULL;
static jclass ioExceptionClass = NULL;
static jclass portUnreachableExceptionClass = NULL;
static jclass closedChannelExceptionClass = NULL;
static jmethodID closedChannelExceptionMethodId = NULL;

/**
 Our `strerror_r` wrapper makes sure that the function is XSI compliant,
 even on platforms where the GNU variant is exposed.
 Note: `strerrbuf` must be initialized to all zeros prior to calling this function.
 XSI or GNU functions do not have such a requirement, but our wrappers do.

 Android exposes the XSI variant by default, see
 https://cs.android.com/android/platform/superproject/+/android16-release:bionic/libc/include/string.h;l=145?q=string.h
 */
#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || __APPLE__ || __ANDROID__) && ! _GNU_SOURCE
    static inline int strerror_r_xsi(int errnum, char *strerrbuf, size_t buflen) {
        return strerror_r(errnum, strerrbuf, buflen);
    }
#else
    static inline int strerror_r_xsi(int errnum, char *strerrbuf, size_t buflen) {
        char* tmp = strerror_r(errnum, strerrbuf, buflen);
        if (strerrbuf[0] == '\0') {
            // Our output buffer was not used. Copy from tmp.
            strncpy(strerrbuf, tmp, buflen - 1); // Use (buflen - 1) to avoid overwriting terminating \0.
        }
        if (errno != 0) {
            return -1;
        }
        return 0;
    }
#endif
// ... (225 more lines)

Dependencies

Frequently Asked Questions

What does netty_unix_errors.c do?
netty_unix_errors.c is a source file in the netty codebase, written in c. It belongs to the NativeTransport domain.
What does netty_unix_errors.c depend on?
netty_unix_errors.c imports 8 module(s): errno.h, jni.h, netty_jni_util.h, netty_unix_errors.h, netty_unix_jni.h, netty_unix_util.h, stdlib.h, string.h.
Where is netty_unix_errors.c in the architecture?
netty_unix_errors.c is located at transport-native-unix-common/src/main/c/netty_unix_errors.c (domain: NativeTransport, directory: transport-native-unix-common/src/main/c).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free