Skip to content

Commit 7318388

Browse files
Dark KirbDarkKirb
Dark Kirb
authored andcommitted
Add DevkitPPC support
DevkitPPC does not support unix sockets natively, meaning that bindings to these functions was removed for powerpc targets with "nintendo" as vendor Suggested target json files: Nintendo Gamecube: ``` { "arch": "powerpc", "data-layout": "E-m:e-p:32:32-i64:64-n32", "dynamic-linking": false, "env": "newlib", "executables": true, "has-elf-tls": false, "has-rpath": true, "linker-flavor": "gcc", "llvm-target": "powerpc-eabi", "max-atomic-width": 32, "os": "dolphin", "target-c-int-width": "32", "target-endian": "big", "target-family": "unix", "target-mcount": "_mcount", "target-pointer-width": "32", "vendor": "nintendo" } ``` Nintendo Wii: ``` { "arch": "powerpc", "data-layout": "E-m:e-p:32:32-i64:64-n32", "dynamic-linking": false, "env": "newlib", "executables": true, "has-elf-tls": false, "has-rpath": true, "linker-flavor": "gcc", "llvm-target": "powerpc-eabi", "max-atomic-width": 32, "os": "revolution", "target-c-int-width": "32", "target-endian": "big", "target-family": "unix", "target-mcount": "_mcount", "target-pointer-width": "32", "vendor": "nintendo" } ```
1 parent 7c3030f commit 7318388

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/unix/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,11 @@ extern "C" {
596596
pub fn getchar_unlocked() -> ::c_int;
597597
pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
598598

599+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
599600
#[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
600601
#[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")]
601602
pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
603+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
602604
#[cfg_attr(
603605
all(target_os = "macos", target_arch = "x86"),
604606
link_name = "connect$UNIX2003"
@@ -614,6 +616,7 @@ extern "C" {
614616
link_name = "listen$UNIX2003"
615617
)]
616618
pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
619+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
617620
#[cfg_attr(
618621
all(target_os = "macos", target_arch = "x86"),
619622
link_name = "accept$UNIX2003"
@@ -623,6 +626,7 @@ extern "C" {
623626
address: *mut sockaddr,
624627
address_len: *mut socklen_t,
625628
) -> ::c_int;
629+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
626630
#[cfg_attr(
627631
all(target_os = "macos", target_arch = "x86"),
628632
link_name = "getpeername$UNIX2003"
@@ -632,6 +636,7 @@ extern "C" {
632636
address: *mut sockaddr,
633637
address_len: *mut socklen_t,
634638
) -> ::c_int;
639+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
635640
#[cfg_attr(
636641
all(target_os = "macos", target_arch = "x86"),
637642
link_name = "getsockname$UNIX2003"
@@ -659,6 +664,7 @@ extern "C" {
659664
protocol: ::c_int,
660665
socket_vector: *mut ::c_int,
661666
) -> ::c_int;
667+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
662668
#[cfg_attr(
663669
all(target_os = "macos", target_arch = "x86"),
664670
link_name = "sendto$UNIX2003"
@@ -1234,13 +1240,15 @@ extern "C" {
12341240
pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
12351241
pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
12361242

1243+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
12371244
#[cfg_attr(target_os = "illumos", link_name = "__xnet_getaddrinfo")]
12381245
pub fn getaddrinfo(
12391246
node: *const c_char,
12401247
service: *const c_char,
12411248
hints: *const addrinfo,
12421249
res: *mut *mut addrinfo,
12431250
) -> ::c_int;
1251+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
12441252
pub fn freeaddrinfo(res: *mut addrinfo);
12451253
pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
12461254
#[cfg_attr(

src/unix/newlib/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ s! {
3333
pub ai_protocol: ::c_int,
3434
pub ai_addrlen: socklen_t,
3535

36+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
3637
#[cfg(target_arch = "xtensa")]
3738
pub ai_addr: *mut sockaddr,
3839

3940
pub ai_canonname: *mut ::c_char,
4041

42+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
4143
#[cfg(not(target_arch = "xtensa"))]
4244
pub ai_addr: *mut sockaddr,
4345

@@ -598,6 +600,7 @@ extern "C" {
598600
pub fn rand() -> ::c_int;
599601
pub fn srand(seed: ::c_uint);
600602

603+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
601604
pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t)
602605
-> ::c_int;
603606
pub fn clock_settime(
@@ -614,6 +617,7 @@ extern "C" {
614617
) -> ::c_int;
615618
pub fn closesocket(sockfd: ::c_int) -> ::c_int;
616619
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
620+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
617621
pub fn recvfrom(
618622
fd: ::c_int,
619623
buf: *mut ::c_void,
@@ -622,6 +626,7 @@ extern "C" {
622626
addr: *mut sockaddr,
623627
addr_len: *mut socklen_t,
624628
) -> isize;
629+
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
625630
pub fn getnameinfo(
626631
sa: *const sockaddr,
627632
salen: socklen_t,
@@ -700,6 +705,9 @@ cfg_if! {
700705
} else if #[cfg(target_arch = "xtensa")] {
701706
mod xtensa;
702707
pub use self::xtensa::*;
708+
} else if #[cfg(target_arch = "powerpc")] {
709+
mod powerpc;
710+
pub use self::powerpc::*;
703711
} else {
704712
// Only tested on ARM so far. Other platforms might have different
705713
// definitions for types and constants.

src/unix/newlib/powerpc/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub type clock_t = ::c_ulong;
2+
pub type c_char = u8;
3+
pub type wchar_t = ::c_int;
4+
5+
pub type c_long = i32;
6+
pub type c_ulong = u32;
7+
8+
// the newlib shipped with devkitPPC does not support the following components:
9+
// - sockaddr
10+
// - AF_INET6
11+
// - FIONBIO
12+
// - POLL*
13+
// - SOL_SOCKET
14+
// - MSG_*

0 commit comments

Comments
 (0)