Sponsored Content
Top Forums Programming C. To segmentation fault or not to segmentation fault, that is the question. Post 303032357 by wisecracker on Friday 15th of March 2019 02:35:37 PM
Old 03-15-2019
@nez...

(Just seen Corona688 post.)

The code was written for a real stock A1200 with HDD, Motorola 68020 32 bit, no FPU nor MMU.
This is a screenshot of the FS-UAE AMIGA emulator for THIS 64 bit MBP, OSX 10.14.1, using 68040 with FPU and MMU, and much more than the stock 2MB RAM, compiling the 'error.c' code that is in the OP using the AMIGA's gcc 2.95.3.

As you can see it IS working!

EDIT:
@C688...

That makes sense but I didn't see it. However the OP's first code block will not compile in gcc 2.95.3 as it crashes out so I am stuck with an 'illegal' operation for my fav' OS.
C. To segmentation fault or not to segmentation fault, that is the question.-68040_fpu_mmupng

Last edited by wisecracker; 03-15-2019 at 03:46 PM.. Reason: See EDIT.
This User Gave Thanks to wisecracker For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

segmentation fault

sometimes for this code i get a segmentation fault for codes llike this : int main{ int * a= 0; int b; a = (int*)malloc(sizeof(int)); ///some code using these variable but no freeing of a if(a){ free(a); a = 0; } return... (3 Replies)
Discussion started by: wojtyla
3 Replies

2. AIX

Segmentation fault

Hi , During execution a backup binary i get following error "Program error 11 (Segmentation fault), saving core file in '/usr/datatools" Riyaz (2 Replies)
Discussion started by: rshaikh
2 Replies

3. Linux

Segmentation fault

Hi, on a linux Red HAT(with Oracle DB 9.2.0.7) I have following error : RMAN> delete obsolete; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 using channel ORA_DISK_1 Segmentation fault What does it mean ? And the solution ? Many thanks. (0 Replies)
Discussion started by: big123456
0 Replies

4. Programming

segmentation fault

If I do this. Assume struct life { char *nolife; } struct life **life; // malloc initialization & everything if(life->nolife == 0) Would I get error at life->nolife if it is equal to 0. wrong accession? (3 Replies)
Discussion started by: joey
3 Replies

5. Programming

Segmentation fault.

I'm getting a segmentation fault. I'm new to Linux programming. Thanks so much for all of your input.:eek: #include </usr/include/mysql++/mysql++.h> #include <stdio.h> #include <iostream> #include <sstream> #include <string.h> using namespace std; int outputToImport(const char*... (1 Reply)
Discussion started by: sepoto
1 Replies

6. Programming

Segmentation fault in C

i have this code int already_there(char *client_names, char *username) { int i; for(i = 0; i<NUM; i++) { printf("HERE\n"); if (strcmp(client_names, username)==0) return(1); } return(0); } and i get a segmentation fault, whats wrong here? (7 Replies)
Discussion started by: omega666
7 Replies

7. UNIX for Advanced & Expert Users

segmentation fault with ps

What does this mean and why is this happening? $ ps -ef | grep ocular Segmentation fault (core dumped) $ ps -ef | grep ocular Segmentation fault (core dumped) $ ps aux | grep ocular Segmentation fault (core dumped) $ ps Segmentation fault (core dumped) $ pkill okular $ ps... (1 Reply)
Discussion started by: cokedude
1 Replies

8. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

9. Homework & Coursework Questions

Segmentation Fault

this is a network programming code to run a rock paper scissors in a client and server. I completed it and it was working without any error. After I added the findWinner function to the server code it starts giving me segmentation fault. -the segmentation fault is fixed Current problem -Also... (3 Replies)
Discussion started by: femchi
3 Replies

10. Solaris

Segmentation fault

Hi Guys, I just installed and booted a zone called testzone. When I logged in remotely and tried changing to root user I get this error: "Segmentation fault" Can someone please help me resolve this? Thanks alot (2 Replies)
Discussion started by: cjashu
2 Replies
FPU_KERN(9)						   BSD Kernel Developer's Manual					       FPU_KERN(9)

NAME
fpu_kern -- facility to use the FPU in the kernel SYNOPSIS
struct fpu_kern_ctx * fpu_kern_alloc_ctx(u_int flags); void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); int fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags); int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); int fpu_kern_thread(u_int flags); int is_fpu_kern_thread(u_int flags); DESCRIPTION
The fpu_kern family of functions allows the use of FPU hardware in kernel code. Modern FPUs are not limited to providing hardware implemen- tation for floating point arithmetic; they offer advanced accelerators for cryptography and other computational-intensive algorithms. These facilities share registers with the FPU hardware. Typical kernel code does not need access to the FPU. Saving a large register file on each entry to the kernel would waste time. When kernel code uses the FPU, the current FPU state must be saved to avoid corrupting the user-mode state, and vice versa. The management of the save and restore is automatic. The processor catches accesses to the FPU registers when the non-current context tries to access them. Explicit calls are required for the allocation of the save area and the notification of the start and end of the code using the FPU. The fpu_kern_alloc_ctx() function allocates the memory used by fpu_kern to track the use of the FPU hardware state and the related software state. The fpu_kern_alloc_ctx() function requires the flags argument, which currently accepts the following flags: FPU_KERN_NOWAIT Do not wait for the available memory if the request could not be satisfied without sleep. 0 No special handling is required. The function returns the allocated context area, or NULL if the allocation failed. The fpu_kern_free_ctx() function frees the context previously allocated by fpu_kern_alloc_ctx(). The fpu_kern_enter() function designates the start of the region of kernel code where the use of the FPU is allowed. Its arguments are: td Currently must be curthread. ctx The context save area previously allocated by fpu_kern_alloc_ctx() and not currently in use by another call to fpu_kern_enter(). flags This argument currently accepts the following flags: FPU_KERN_NORMAL Indicates that the caller intends to access the full FPU state. Must be specified currently. FPU_KERN_KTHR Indicates that no saving of the current FPU state should be performed, if the thread called fpu_kern_thread(9) function. This is intended to minimize code duplication in callers which could be used from both kernel thread and syscall contexts. The fpu_kern_leave() function correctly handles such con- texts. The function does not sleep or block. It could cause the Device Not Available exception during execution, and on the first FPU access after the function returns, as well as after each context switch (see Intel Software Developer Manual for the reference). Currently, no errors are defined which can be returned by fpu_kern_enter() to the caller. The fpu_kern_leave() function ends the region started by fpu_kern_enter(). The uses of FPU in the kernel after the call to fpu_kern_leave() are erronous until the next call to fpu_kern_enter() is performed. The function takes the td thread argument, which currently must be curthread, and the ctx context pointer, previously passed to fpu_kern_enter(). After the function returns, the context may be freed or reused by other invocation of fpu_kern_enter(). There are no errors defined for the function, it always returns 0. The fpu_kern_thread() function enables an optimization for threads which never leave to the usermode. The current thread will reuse the usermode save area for the kernel FPU state instead of requiring an explicitly allocated context. There are no flags defined for the func- tion, and no error states that the function returns. Once this function has been called, neither fpu_kern_enter() nor fpu_kern_leave() is required to be called and the fpu is available for use in the calling thread. The is_fpu_kern_thread() function returns the boolean indicating whether the current thread entered the mode enabled by fpu_kern_thread(). There is currently no flags defined for the function, the return value is true if the current thread have the permanent FPU save area, and false otherwise. NOTES
The fpu_kern is currently implemented only for the i386 and amd64 architectures. There is no way to handle floating point exceptions raised from kernel mode. The unused flags arguments to the fpu_kern functions are to be extended to allow specification of the set of the FPU hardware state used by the code region. This would allow optimizations of saving and restoring the state. AUTHORS
The fpu_kern facitily and this manual page were written by Konstantin Belousov <kib@FreeBSD.org>. BSD
October 23, 2014 BSD
All times are GMT -4. The time now is 05:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy