michael@0: /* michael@0: * Copyright (C) 2009 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef NATIVE_HANDLE_H_ michael@0: #define NATIVE_HANDLE_H_ michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: typedef struct michael@0: { michael@0: int version; /* sizeof(native_handle_t) */ michael@0: int numFds; /* number of file-descriptors at &data[0] */ michael@0: int numInts; /* number of ints at &data[numFds] */ michael@0: int data[0]; /* numFds + numInts ints */ michael@0: } native_handle_t; michael@0: michael@0: michael@0: /* keep the old definition for backward source-compatibility */ michael@0: typedef native_handle_t native_handle; michael@0: michael@0: /* michael@0: * native_handle_close michael@0: * michael@0: * closes the file descriptors contained in this native_handle_t michael@0: * michael@0: * return 0 on success, or a negative error code on failure michael@0: * michael@0: */ michael@0: int native_handle_close(const native_handle_t* h); michael@0: michael@0: michael@0: /* michael@0: * native_handle_create michael@0: * michael@0: * creates a native_handle_t and initializes it. must be destroyed with michael@0: * native_handle_delete(). michael@0: * michael@0: */ michael@0: native_handle_t* native_handle_create(int numFds, int numInts); michael@0: michael@0: /* michael@0: * native_handle_delete michael@0: * michael@0: * frees a native_handle_t allocated with native_handle_create(). michael@0: * This ONLY frees the memory allocated for the native_handle_t, but doesn't michael@0: * close the file descriptors; which can be achieved with native_handle_close(). michael@0: * michael@0: * return 0 on success, or a negative error code on failure michael@0: * michael@0: */ michael@0: int native_handle_delete(native_handle_t* h); michael@0: michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: michael@0: #endif /* NATIVE_HANDLE_H_ */