Text file src/runtime/sys_linux_mips64x.s

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build linux && (mips64 || mips64le)
     6  
     7  //
     8  // System calls and other sys.stuff for mips64, Linux
     9  //
    10  
    11  #include "go_asm.h"
    12  #include "go_tls.h"
    13  #include "textflag.h"
    14  
    15  #define AT_FDCWD -100
    16  
    17  #define SYS_exit		5058
    18  #define SYS_read		5000
    19  #define SYS_write		5001
    20  #define SYS_close		5003
    21  #define SYS_getpid		5038
    22  #define SYS_kill		5060
    23  #define SYS_fcntl		5070
    24  #define SYS_mmap		5009
    25  #define SYS_munmap		5011
    26  #define SYS_setitimer		5036
    27  #define SYS_clone		5055
    28  #define SYS_nanosleep		5034
    29  #define SYS_sched_yield		5023
    30  #define SYS_rt_sigreturn	5211
    31  #define SYS_rt_sigaction	5013
    32  #define SYS_rt_sigprocmask	5014
    33  #define SYS_sigaltstack		5129
    34  #define SYS_madvise		5027
    35  #define SYS_mincore		5026
    36  #define SYS_gettid		5178
    37  #define SYS_futex		5194
    38  #define SYS_sched_getaffinity	5196
    39  #define SYS_exit_group		5205
    40  #define SYS_epoll_create	5207
    41  #define SYS_epoll_ctl		5208
    42  #define SYS_timer_create	5216
    43  #define SYS_timer_settime	5217
    44  #define SYS_timer_delete	5220
    45  #define SYS_tgkill		5225
    46  #define SYS_openat		5247
    47  #define SYS_epoll_pwait		5272
    48  #define SYS_clock_gettime	5222
    49  #define SYS_epoll_create1	5285
    50  #define SYS_brk			5012
    51  #define SYS_pipe2		5287
    52  
    53  TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4
    54  	MOVW	code+0(FP), R4
    55  	MOVV	$SYS_exit_group, R2
    56  	SYSCALL
    57  	RET
    58  
    59  // func exitThread(wait *uint32)
    60  TEXT runtime·exitThread(SB),NOSPLIT|NOFRAME,$0-8
    61  	MOVV	wait+0(FP), R1
    62  	// We're done using the stack.
    63  	MOVW	$0, R2
    64  	SYNC
    65  	MOVW	R2, (R1)
    66  	SYNC
    67  	MOVW	$0, R4	// exit code
    68  	MOVV	$SYS_exit, R2
    69  	SYSCALL
    70  	JMP	0(PC)
    71  
    72  TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20
    73  	// This uses openat instead of open, because Android O blocks open.
    74  	MOVW	$AT_FDCWD, R4 // AT_FDCWD, so this acts like open
    75  	MOVV	name+0(FP), R5
    76  	MOVW	mode+8(FP), R6
    77  	MOVW	perm+12(FP), R7
    78  	MOVV	$SYS_openat, R2
    79  	SYSCALL
    80  	BEQ	R7, 2(PC)
    81  	MOVW	$-1, R2
    82  	MOVW	R2, ret+16(FP)
    83  	RET
    84  
    85  TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12
    86  	MOVW	fd+0(FP), R4
    87  	MOVV	$SYS_close, R2
    88  	SYSCALL
    89  	BEQ	R7, 2(PC)
    90  	MOVW	$-1, R2
    91  	MOVW	R2, ret+8(FP)
    92  	RET
    93  
    94  TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28
    95  	MOVV	fd+0(FP), R4
    96  	MOVV	p+8(FP), R5
    97  	MOVW	n+16(FP), R6
    98  	MOVV	$SYS_write, R2
    99  	SYSCALL
   100  	BEQ	R7, 2(PC)
   101  	SUBVU	R2, R0, R2	// caller expects negative errno
   102  	MOVW	R2, ret+24(FP)
   103  	RET
   104  
   105  TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28
   106  	MOVW	fd+0(FP), R4
   107  	MOVV	p+8(FP), R5
   108  	MOVW	n+16(FP), R6
   109  	MOVV	$SYS_read, R2
   110  	SYSCALL
   111  	BEQ	R7, 2(PC)
   112  	SUBVU	R2, R0, R2	// caller expects negative errno
   113  	MOVW	R2, ret+24(FP)
   114  	RET
   115  
   116  // func pipe() (r, w int32, errno int32)
   117  TEXT runtime·pipe(SB),NOSPLIT|NOFRAME,$0-12
   118  	MOVV	$r+0(FP), R4
   119  	MOVV	R0, R5
   120  	MOVV	$SYS_pipe2, R2
   121  	SYSCALL
   122  	BEQ	R7, 2(PC)
   123  	SUBVU	R2, R0, R2	// caller expects negative errno
   124  	MOVW	R2, errno+8(FP)
   125  	RET
   126  
   127  // func pipe2(flags int32) (r, w int32, errno int32)
   128  TEXT runtime·pipe2(SB),NOSPLIT|NOFRAME,$0-20
   129  	MOVV	$r+8(FP), R4
   130  	MOVW	flags+0(FP), R5
   131  	MOVV	$SYS_pipe2, R2
   132  	SYSCALL
   133  	BEQ	R7, 2(PC)
   134  	SUBVU	R2, R0, R2	// caller expects negative errno
   135  	MOVW	R2, errno+16(FP)
   136  	RET
   137  
   138  TEXT runtime·usleep(SB),NOSPLIT,$16-4
   139  	MOVWU	usec+0(FP), R3
   140  	MOVV	R3, R5
   141  	MOVW	$1000000, R4
   142  	DIVVU	R4, R3
   143  	MOVV	LO, R3
   144  	MOVV	R3, 8(R29)
   145  	MOVW	$1000, R4
   146  	MULVU	R3, R4
   147  	MOVV	LO, R4
   148  	SUBVU	R4, R5
   149  	MOVV	R5, 16(R29)
   150  
   151  	// nanosleep(&ts, 0)
   152  	ADDV	$8, R29, R4
   153  	MOVW	$0, R5
   154  	MOVV	$SYS_nanosleep, R2
   155  	SYSCALL
   156  	RET
   157  
   158  TEXT runtime·gettid(SB),NOSPLIT,$0-4
   159  	MOVV	$SYS_gettid, R2
   160  	SYSCALL
   161  	MOVW	R2, ret+0(FP)
   162  	RET
   163  
   164  TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0
   165  	MOVV	$SYS_getpid, R2
   166  	SYSCALL
   167  	MOVW	R2, R16
   168  	MOVV	$SYS_gettid, R2
   169  	SYSCALL
   170  	MOVW	R2, R5	// arg 2 tid
   171  	MOVW	R16, R4	// arg 1 pid
   172  	MOVW	sig+0(FP), R6	// arg 3
   173  	MOVV	$SYS_tgkill, R2
   174  	SYSCALL
   175  	RET
   176  
   177  TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0
   178  	MOVV	$SYS_getpid, R2
   179  	SYSCALL
   180  	MOVW	R2, R4	// arg 1 pid
   181  	MOVW	sig+0(FP), R5	// arg 2
   182  	MOVV	$SYS_kill, R2
   183  	SYSCALL
   184  	RET
   185  
   186  TEXT ·getpid(SB),NOSPLIT|NOFRAME,$0-8
   187  	MOVV	$SYS_getpid, R2
   188  	SYSCALL
   189  	MOVV	R2, ret+0(FP)
   190  	RET
   191  
   192  TEXT ·tgkill(SB),NOSPLIT|NOFRAME,$0-24
   193  	MOVV	tgid+0(FP), R4
   194  	MOVV	tid+8(FP), R5
   195  	MOVV	sig+16(FP), R6
   196  	MOVV	$SYS_tgkill, R2
   197  	SYSCALL
   198  	RET
   199  
   200  TEXT runtime·setitimer(SB),NOSPLIT|NOFRAME,$0-24
   201  	MOVW	mode+0(FP), R4
   202  	MOVV	new+8(FP), R5
   203  	MOVV	old+16(FP), R6
   204  	MOVV	$SYS_setitimer, R2
   205  	SYSCALL
   206  	RET
   207  
   208  TEXT runtime·timer_create(SB),NOSPLIT,$0-28
   209  	MOVW	clockid+0(FP), R4
   210  	MOVV	sevp+8(FP), R5
   211  	MOVV	timerid+16(FP), R6
   212  	MOVV	$SYS_timer_create, R2
   213  	SYSCALL
   214  	MOVW	R2, ret+24(FP)
   215  	RET
   216  
   217  TEXT runtime·timer_settime(SB),NOSPLIT,$0-28
   218  	MOVW	timerid+0(FP), R4
   219  	MOVW	flags+4(FP), R5
   220  	MOVV	new+8(FP), R6
   221  	MOVV	old+16(FP), R7
   222  	MOVV	$SYS_timer_settime, R2
   223  	SYSCALL
   224  	MOVW	R2, ret+24(FP)
   225  	RET
   226  
   227  TEXT runtime·timer_delete(SB),NOSPLIT,$0-12
   228  	MOVW	timerid+0(FP), R4
   229  	MOVV	$SYS_timer_delete, R2
   230  	SYSCALL
   231  	MOVW	R2, ret+8(FP)
   232  	RET
   233  
   234  TEXT runtime·mincore(SB),NOSPLIT|NOFRAME,$0-28
   235  	MOVV	addr+0(FP), R4
   236  	MOVV	n+8(FP), R5
   237  	MOVV	dst+16(FP), R6
   238  	MOVV	$SYS_mincore, R2
   239  	SYSCALL
   240  	SUBVU	R2, R0, R2	// caller expects negative errno
   241  	MOVW	R2, ret+24(FP)
   242  	RET
   243  
   244  // func walltime() (sec int64, nsec int32)
   245  TEXT runtime·walltime(SB),NOSPLIT,$16-12
   246  	MOVV	R29, R16	// R16 is unchanged by C code
   247  	MOVV	R29, R1
   248  
   249  	MOVV	g_m(g), R17	// R17 = m
   250  
   251  	// Set vdsoPC and vdsoSP for SIGPROF traceback.
   252  	// Save the old values on stack and restore them on exit,
   253  	// so this function is reentrant.
   254  	MOVV	m_vdsoPC(R17), R2
   255  	MOVV	m_vdsoSP(R17), R3
   256  	MOVV	R2, 8(R29)
   257  	MOVV	R3, 16(R29)
   258  
   259  	MOVV	$ret-8(FP), R2 // caller's SP
   260  	MOVV	R31, m_vdsoPC(R17)
   261  	MOVV	R2, m_vdsoSP(R17)
   262  
   263  	MOVV	m_curg(R17), R4
   264  	MOVV	g, R5
   265  	BNE	R4, R5, noswitch
   266  
   267  	MOVV	m_g0(R17), R4
   268  	MOVV	(g_sched+gobuf_sp)(R4), R1	// Set SP to g0 stack
   269  
   270  noswitch:
   271  	SUBV	$16, R1
   272  	AND	$~15, R1	// Align for C code
   273  	MOVV	R1, R29
   274  
   275  	MOVW	$0, R4 // CLOCK_REALTIME
   276  	MOVV	$0(R29), R5
   277  
   278  	MOVV	runtime·vdsoClockgettimeSym(SB), R25
   279  	BEQ	R25, fallback
   280  
   281  	JAL	(R25)
   282  	// check on vdso call return for kernel compatibility
   283  	// see https://golang.org/issues/39046
   284  	// if we get any error make fallback permanent.
   285  	BEQ	R2, R0, finish
   286  	MOVV	R0, runtime·vdsoClockgettimeSym(SB)
   287  	MOVW	$0, R4 // CLOCK_REALTIME
   288  	MOVV	$0(R29), R5
   289  	JMP	fallback
   290  
   291  finish:
   292  	MOVV	0(R29), R3	// sec
   293  	MOVV	8(R29), R5	// nsec
   294  
   295  	MOVV	R16, R29	// restore SP
   296  	// Restore vdsoPC, vdsoSP
   297  	// We don't worry about being signaled between the two stores.
   298  	// If we are not in a signal handler, we'll restore vdsoSP to 0,
   299  	// and no one will care about vdsoPC. If we are in a signal handler,
   300  	// we cannot receive another signal.
   301  	MOVV	16(R29), R1
   302  	MOVV	R1, m_vdsoSP(R17)
   303  	MOVV	8(R29), R1
   304  	MOVV	R1, m_vdsoPC(R17)
   305  
   306  	MOVV	R3, sec+0(FP)
   307  	MOVW	R5, nsec+8(FP)
   308  	RET
   309  
   310  fallback:
   311  	MOVV	$SYS_clock_gettime, R2
   312  	SYSCALL
   313  	JMP finish
   314  
   315  TEXT runtime·nanotime1(SB),NOSPLIT,$16-8
   316  	MOVV	R29, R16	// R16 is unchanged by C code
   317  	MOVV	R29, R1
   318  
   319  	MOVV	g_m(g), R17	// R17 = m
   320  
   321  	// Set vdsoPC and vdsoSP for SIGPROF traceback.
   322  	// Save the old values on stack and restore them on exit,
   323  	// so this function is reentrant.
   324  	MOVV	m_vdsoPC(R17), R2
   325  	MOVV	m_vdsoSP(R17), R3
   326  	MOVV	R2, 8(R29)
   327  	MOVV	R3, 16(R29)
   328  
   329  	MOVV	$ret-8(FP), R2 // caller's SP
   330  	MOVV	R31, m_vdsoPC(R17)
   331  	MOVV	R2, m_vdsoSP(R17)
   332  
   333  	MOVV	m_curg(R17), R4
   334  	MOVV	g, R5
   335  	BNE	R4, R5, noswitch
   336  
   337  	MOVV	m_g0(R17), R4
   338  	MOVV	(g_sched+gobuf_sp)(R4), R1	// Set SP to g0 stack
   339  
   340  noswitch:
   341  	SUBV	$16, R1
   342  	AND	$~15, R1	// Align for C code
   343  	MOVV	R1, R29
   344  
   345  	MOVW	$1, R4 // CLOCK_MONOTONIC
   346  	MOVV	$0(R29), R5
   347  
   348  	MOVV	runtime·vdsoClockgettimeSym(SB), R25
   349  	BEQ	R25, fallback
   350  
   351  	JAL	(R25)
   352  	// see walltime for detail
   353  	BEQ	R2, R0, finish
   354  	MOVV	R0, runtime·vdsoClockgettimeSym(SB)
   355  	MOVW	$1, R4 // CLOCK_MONOTONIC
   356  	MOVV	$0(R29), R5
   357  	JMP	fallback
   358  
   359  finish:
   360  	MOVV	0(R29), R3	// sec
   361  	MOVV	8(R29), R5	// nsec
   362  
   363  	MOVV	R16, R29	// restore SP
   364  	// Restore vdsoPC, vdsoSP
   365  	// We don't worry about being signaled between the two stores.
   366  	// If we are not in a signal handler, we'll restore vdsoSP to 0,
   367  	// and no one will care about vdsoPC. If we are in a signal handler,
   368  	// we cannot receive another signal.
   369  	MOVV	16(R29), R1
   370  	MOVV	R1, m_vdsoSP(R17)
   371  	MOVV	8(R29), R1
   372  	MOVV	R1, m_vdsoPC(R17)
   373  
   374  	// sec is in R3, nsec in R5
   375  	// return nsec in R3
   376  	MOVV	$1000000000, R4
   377  	MULVU	R4, R3
   378  	MOVV	LO, R3
   379  	ADDVU	R5, R3
   380  	MOVV	R3, ret+0(FP)
   381  	RET
   382  
   383  fallback:
   384  	MOVV	$SYS_clock_gettime, R2
   385  	SYSCALL
   386  	JMP	finish
   387  
   388  TEXT runtime·rtsigprocmask(SB),NOSPLIT|NOFRAME,$0-28
   389  	MOVW	how+0(FP), R4
   390  	MOVV	new+8(FP), R5
   391  	MOVV	old+16(FP), R6
   392  	MOVW	size+24(FP), R7
   393  	MOVV	$SYS_rt_sigprocmask, R2
   394  	SYSCALL
   395  	BEQ	R7, 2(PC)
   396  	MOVV	R0, 0xf1(R0)	// crash
   397  	RET
   398  
   399  TEXT runtime·rt_sigaction(SB),NOSPLIT|NOFRAME,$0-36
   400  	MOVV	sig+0(FP), R4
   401  	MOVV	new+8(FP), R5
   402  	MOVV	old+16(FP), R6
   403  	MOVV	size+24(FP), R7
   404  	MOVV	$SYS_rt_sigaction, R2
   405  	SYSCALL
   406  	BEQ	R7, 2(PC)
   407  	SUBVU	R2, R0, R2	// caller expects negative errno
   408  	MOVW	R2, ret+32(FP)
   409  	RET
   410  
   411  TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
   412  	MOVW	sig+8(FP), R4
   413  	MOVV	info+16(FP), R5
   414  	MOVV	ctx+24(FP), R6
   415  	MOVV	fn+0(FP), R25
   416  	JAL	(R25)
   417  	RET
   418  
   419  TEXT runtime·sigtramp(SB),NOSPLIT,$64
   420  	// initialize REGSB = PC&0xffffffff00000000
   421  	BGEZAL	R0, 1(PC)
   422  	SRLV	$32, R31, RSB
   423  	SLLV	$32, RSB
   424  
   425  	// this might be called in external code context,
   426  	// where g is not set.
   427  	MOVB	runtime·iscgo(SB), R1
   428  	BEQ	R1, 2(PC)
   429  	JAL	runtime·load_g(SB)
   430  
   431  	MOVW	R4, 8(R29)
   432  	MOVV	R5, 16(R29)
   433  	MOVV	R6, 24(R29)
   434  	MOVV	$runtime·sigtrampgo(SB), R1
   435  	JAL	(R1)
   436  	RET
   437  
   438  TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0
   439  	JMP	runtime·sigtramp(SB)
   440  
   441  TEXT runtime·mmap(SB),NOSPLIT|NOFRAME,$0
   442  	MOVV	addr+0(FP), R4
   443  	MOVV	n+8(FP), R5
   444  	MOVW	prot+16(FP), R6
   445  	MOVW	flags+20(FP), R7
   446  	MOVW	fd+24(FP), R8
   447  	MOVW	off+28(FP), R9
   448  
   449  	MOVV	$SYS_mmap, R2
   450  	SYSCALL
   451  	BEQ	R7, ok
   452  	MOVV	$0, p+32(FP)
   453  	MOVV	R2, err+40(FP)
   454  	RET
   455  ok:
   456  	MOVV	R2, p+32(FP)
   457  	MOVV	$0, err+40(FP)
   458  	RET
   459  
   460  TEXT runtime·munmap(SB),NOSPLIT|NOFRAME,$0
   461  	MOVV	addr+0(FP), R4
   462  	MOVV	n+8(FP), R5
   463  	MOVV	$SYS_munmap, R2
   464  	SYSCALL
   465  	BEQ	R7, 2(PC)
   466  	MOVV	R0, 0xf3(R0)	// crash
   467  	RET
   468  
   469  TEXT runtime·madvise(SB),NOSPLIT|NOFRAME,$0
   470  	MOVV	addr+0(FP), R4
   471  	MOVV	n+8(FP), R5
   472  	MOVW	flags+16(FP), R6
   473  	MOVV	$SYS_madvise, R2
   474  	SYSCALL
   475  	MOVW	R2, ret+24(FP)
   476  	RET
   477  
   478  // int64 futex(int32 *uaddr, int32 op, int32 val,
   479  //	struct timespec *timeout, int32 *uaddr2, int32 val2);
   480  TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0
   481  	MOVV	addr+0(FP), R4
   482  	MOVW	op+8(FP), R5
   483  	MOVW	val+12(FP), R6
   484  	MOVV	ts+16(FP), R7
   485  	MOVV	addr2+24(FP), R8
   486  	MOVW	val3+32(FP), R9
   487  	MOVV	$SYS_futex, R2
   488  	SYSCALL
   489  	BEQ	R7, 2(PC)
   490  	SUBVU	R2, R0, R2	// caller expects negative errno
   491  	MOVW	R2, ret+40(FP)
   492  	RET
   493  
   494  // int64 clone(int32 flags, void *stk, M *mp, G *gp, void (*fn)(void));
   495  TEXT runtime·clone(SB),NOSPLIT|NOFRAME,$0
   496  	MOVW	flags+0(FP), R4
   497  	MOVV	stk+8(FP), R5
   498  
   499  	// Copy mp, gp, fn off parent stack for use by child.
   500  	// Careful: Linux system call clobbers ???.
   501  	MOVV	mp+16(FP), R16
   502  	MOVV	gp+24(FP), R17
   503  	MOVV	fn+32(FP), R18
   504  
   505  	MOVV	R16, -8(R5)
   506  	MOVV	R17, -16(R5)
   507  	MOVV	R18, -24(R5)
   508  	MOVV	$1234, R16
   509  	MOVV	R16, -32(R5)
   510  
   511  	MOVV	$SYS_clone, R2
   512  	SYSCALL
   513  	BEQ	R7, 2(PC)
   514  	SUBVU	R2, R0, R2	// caller expects negative errno
   515  
   516  	// In parent, return.
   517  	BEQ	R2, 3(PC)
   518  	MOVW	R2, ret+40(FP)
   519  	RET
   520  
   521  	// In child, on new stack.
   522  	MOVV	-32(R29), R16
   523  	MOVV	$1234, R1
   524  	BEQ	R16, R1, 2(PC)
   525  	MOVV	R0, 0(R0)
   526  
   527  	// Initialize m->procid to Linux tid
   528  	MOVV	$SYS_gettid, R2
   529  	SYSCALL
   530  
   531  	MOVV	-24(R29), R18		// fn
   532  	MOVV	-16(R29), R17		// g
   533  	MOVV	-8(R29), R16		// m
   534  
   535  	BEQ	R16, nog
   536  	BEQ	R17, nog
   537  
   538  	MOVV	R2, m_procid(R16)
   539  
   540  	// TODO: setup TLS.
   541  
   542  	// In child, set up new stack
   543  	MOVV	R16, g_m(R17)
   544  	MOVV	R17, g
   545  	//CALL	runtime·stackcheck(SB)
   546  
   547  nog:
   548  	// Call fn
   549  	JAL	(R18)
   550  
   551  	// It shouldn't return.	 If it does, exit that thread.
   552  	MOVW	$111, R4
   553  	MOVV	$SYS_exit, R2
   554  	SYSCALL
   555  	JMP	-3(PC)	// keep exiting
   556  
   557  TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0
   558  	MOVV	new+0(FP), R4
   559  	MOVV	old+8(FP), R5
   560  	MOVV	$SYS_sigaltstack, R2
   561  	SYSCALL
   562  	BEQ	R7, 2(PC)
   563  	MOVV	R0, 0xf1(R0)	// crash
   564  	RET
   565  
   566  TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0
   567  	MOVV	$SYS_sched_yield, R2
   568  	SYSCALL
   569  	RET
   570  
   571  TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0
   572  	MOVV	pid+0(FP), R4
   573  	MOVV	len+8(FP), R5
   574  	MOVV	buf+16(FP), R6
   575  	MOVV	$SYS_sched_getaffinity, R2
   576  	SYSCALL
   577  	BEQ	R7, 2(PC)
   578  	SUBVU	R2, R0, R2	// caller expects negative errno
   579  	MOVW	R2, ret+24(FP)
   580  	RET
   581  
   582  // int32 runtime·epollcreate(int32 size);
   583  TEXT runtime·epollcreate(SB),NOSPLIT|NOFRAME,$0
   584  	MOVW    size+0(FP), R4
   585  	MOVV	$SYS_epoll_create, R2
   586  	SYSCALL
   587  	BEQ	R7, 2(PC)
   588  	SUBVU	R2, R0, R2	// caller expects negative errno
   589  	MOVW	R2, ret+8(FP)
   590  	RET
   591  
   592  // int32 runtime·epollcreate1(int32 flags);
   593  TEXT runtime·epollcreate1(SB),NOSPLIT|NOFRAME,$0
   594  	MOVW	flags+0(FP), R4
   595  	MOVV	$SYS_epoll_create1, R2
   596  	SYSCALL
   597  	BEQ	R7, 2(PC)
   598  	SUBVU	R2, R0, R2	// caller expects negative errno
   599  	MOVW	R2, ret+8(FP)
   600  	RET
   601  
   602  // func epollctl(epfd, op, fd int32, ev *epollEvent) int
   603  TEXT runtime·epollctl(SB),NOSPLIT|NOFRAME,$0
   604  	MOVW	epfd+0(FP), R4
   605  	MOVW	op+4(FP), R5
   606  	MOVW	fd+8(FP), R6
   607  	MOVV	ev+16(FP), R7
   608  	MOVV	$SYS_epoll_ctl, R2
   609  	SYSCALL
   610  	SUBVU	R2, R0, R2	// caller expects negative errno
   611  	MOVW	R2, ret+24(FP)
   612  	RET
   613  
   614  // int32 runtime·epollwait(int32 epfd, EpollEvent *ev, int32 nev, int32 timeout);
   615  TEXT runtime·epollwait(SB),NOSPLIT|NOFRAME,$0
   616  	// This uses pwait instead of wait, because Android O blocks wait.
   617  	MOVW	epfd+0(FP), R4
   618  	MOVV	ev+8(FP), R5
   619  	MOVW	nev+16(FP), R6
   620  	MOVW	timeout+20(FP), R7
   621  	MOVV	$0, R8
   622  	MOVV	$SYS_epoll_pwait, R2
   623  	SYSCALL
   624  	BEQ	R7, 2(PC)
   625  	SUBVU	R2, R0, R2	// caller expects negative errno
   626  	MOVW	R2, ret+24(FP)
   627  	RET
   628  
   629  // void runtime·closeonexec(int32 fd);
   630  TEXT runtime·closeonexec(SB),NOSPLIT|NOFRAME,$0
   631  	MOVW    fd+0(FP), R4  // fd
   632  	MOVV    $2, R5  // F_SETFD
   633  	MOVV    $1, R6  // FD_CLOEXEC
   634  	MOVV	$SYS_fcntl, R2
   635  	SYSCALL
   636  	RET
   637  
   638  // func runtime·setNonblock(int32 fd)
   639  TEXT runtime·setNonblock(SB),NOSPLIT|NOFRAME,$0-4
   640  	MOVW	fd+0(FP), R4 // fd
   641  	MOVV	$3, R5	// F_GETFL
   642  	MOVV	$0, R6
   643  	MOVV	$SYS_fcntl, R2
   644  	SYSCALL
   645  	MOVW	$0x80, R6 // O_NONBLOCK
   646  	OR	R2, R6
   647  	MOVW	fd+0(FP), R4 // fd
   648  	MOVV	$4, R5	// F_SETFL
   649  	MOVV	$SYS_fcntl, R2
   650  	SYSCALL
   651  	RET
   652  
   653  // func sbrk0() uintptr
   654  TEXT runtime·sbrk0(SB),NOSPLIT|NOFRAME,$0-8
   655  	// Implemented as brk(NULL).
   656  	MOVV	$0, R4
   657  	MOVV	$SYS_brk, R2
   658  	SYSCALL
   659  	MOVV	R2, ret+0(FP)
   660  	RET
   661  
   662  TEXT runtime·access(SB),$0-20
   663  	MOVV	R0, 2(R0) // unimplemented, only needed for android; declared in stubs_linux.go
   664  	MOVW	R0, ret+16(FP) // for vet
   665  	RET
   666  
   667  TEXT runtime·connect(SB),$0-28
   668  	MOVV	R0, 2(R0) // unimplemented, only needed for android; declared in stubs_linux.go
   669  	MOVW	R0, ret+24(FP) // for vet
   670  	RET
   671  
   672  TEXT runtime·socket(SB),$0-20
   673  	MOVV	R0, 2(R0) // unimplemented, only needed for android; declared in stubs_linux.go
   674  	MOVW	R0, ret+16(FP) // for vet
   675  	RET
   676  

View as plain text