xref: /optee_os/lib/libutils/isoc/fwrite.c (revision 12fc37711783247b0d05fdc271ef007f4930767b)
1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright (c) 2020, Huawei Technologies Co., Ltd
4  */
5 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <unistd.h>
9 
10 size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
11 {
12 	int fd = 0;
13 
14 	if (stream == stdout)
15 		fd = 1;
16 	else if (stream == stderr)
17 		fd = 2;
18 	else
19 		abort();
20 
21 	return write(fd, ptr, size * nmemb);
22 }
23