socket.c revision bf1b1e6c7f2fb0f912940232c7807506e63df2d2
1/* 2 * Copyright 2012, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include <unistd.h> 18#include <sys/socket.h> 19#include <sys/linux-syscalls.h> 20#include <socket_portable.h> 21 22 23#if SOCK_STREAM==SOCK_STREAM_PORTABLE 24#error Bad build environment 25#endif 26 27static inline int mips_change_type(int type) 28{ 29 switch (type) { 30 case SOCK_STREAM_PORTABLE: return SOCK_STREAM; 31 case SOCK_DGRAM_PORTABLE: return SOCK_DGRAM; 32 case SOCK_RAW_PORTABLE: return SOCK_RAW; 33 case SOCK_RDM_PORTABLE: return SOCK_RDM; 34 case SOCK_SEQPACKET_PORTABLE: return SOCK_SEQPACKET; 35 case SOCK_PACKET_PORTABLE: return SOCK_PACKET; 36 } 37 return type; 38} 39 40extern int socket(int, int, int); 41 42int socket_portable(int domain, int type, int protocol) { 43 return socket(domain, mips_change_type(type), protocol); 44} 45